/ SeriousOJ /

Record Detail

Accepted


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

Code

// Author: Shawn Das Shachin-->(shawn_das)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define pb push_back
#define mod 1000000007
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.rbegin(),v.rend())
#define OPTIMIZE_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define setbit(x) __builtin_popcount(x);
#define printp(v) { for(auto &it : v) std::cout << it.first << " " << it.second << std::endl; }
#define printarr(arr) { for(auto &it : arr) std::cout << it << " "; std::cout << std::endl; }

void solve() {
    int n;
    cin>>n;
    if(n%2==0){
        for(int i=1; i<=n; i++){
            if(i%2){
                cout<<i+1<<" ";
            }
            else{
                cout<<i-1<<" ";
            }
        }
        cout<<endl;
    }
    else{
        for(int i=1; i<=n-2; i++){
            if(i%2){
                cout<<i+1<<" ";
            }
            else{
                cout<<i-1<<" ";
            }
        }
        cout<<n<<" "<< n-2<<endl;
        
    }
}

int main() {
    OPTIMIZE_IO;
    int 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:43:33
Judged At
2025-07-14 15:43:33
Judged By
Score
100
Total Time
2ms
Peak Memory
532.0 KiB