/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 2ms 532.0 KiB

Code

/*
*   @author:- SYEDA SADIATUL JANNAT TUSHI
*   CF ID : Baby_Tigress_Tushi
*   BANGLADESH , SYLHET.
*/

#include <bits/stdc++.h>
using namespace std;

#define endl          '\n'
#define ll            long long
#define vi            vector<ll>
#define pii           pair<ll,ll>
#define vii           vector<pii>
#define sz(x)         (int)x.size()
#define be(x)         x.begin(), x.end()
#define srt(v)        sort(v.begin(),v.end())
#define rsrt(v)       sort(v.rbegin(),v.rend())
#define fl(i, a, b)   for(ll i = (a); i < (b); i++)
#define print(v)      for(auto e:v) cout<<e<<" "; cout<<endl;
#define InShaAllah    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);



void solve(){
  ll n;
  cin >> n;
  vi a;

  fl(i,0,n){
    a.push_back(i+1);
  }

  if(n%2==0){
    fl(i,0,n-1){
      if(i%2==0){
        swap(a[i],a[i+1]);
      }
    }
  }
  else{
    fl(i,0,n-2){
      if(i%2==0){
        swap(a[i],a[i+1]);
      }
    }
    swap(a[n-2],a[n-1]);
  }

  print(a);
}

int main() {
  InShaAllah

  ll t = 1;
  cin >> t;
  while (t--) {
      solve();
  }
  return 0;
}

Information

Submit By
Type
Submission
Problem
P1210 A. Smallest Permutation
Contest
Educational Round 1
Language
C++17 (G++ 13.2.0)
Submit At
2025-07-14 15:48:37
Judged At
2025-07-14 15:48:37
Judged By
Score
100
Total Time
2ms
Peak Memory
532.0 KiB