/ SeriousOJ /

Record Detail

Accepted


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

Code

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll t;
    cin >> t;
    while (t--){
        ll n;
        cin >> n;
        deque<int> a;
        for(ll i=1;i<=n;i++)a.push_back(i);
        for(ll i=0;i<n;i+=2){
            if(n%2!=0 && i==n-1){
                break;
            }
            swap(a[i],a[i+1]);
        }
        
        if(n%2!=0){
            swap(a[n-1],a[n-2]);
        }
        for(ll i=0;i<a.size();i++){
            cout << a[i] << " ";
        }
        cout << endl;
    }
}

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 16:01:34
Judged At
2025-07-14 16:01:34
Judged By
Score
100
Total Time
2ms
Peak Memory
532.0 KiB