/ SeriousOJ /

Record Detail

Accepted


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

Code

#include <bits/stdc++.h>
using namespace std;
void solve() {
    int n;
    cin >> n;
    vector<long long>t;
    for(int i = 1; i <= n; i++){
        t.push_back(i);
    }
    if(n%2 == 0){
            for(int i = 0; i < t.size(); i+= 2){
            swap(t[i],t[i+1]);
        }
    }
    else{
         for(int i = 0; i < t.size() - 1; i+= 2){
            swap(t[i],t[i+1]);
        }
        swap(t[n-2],t[n-1]);
    }
    for(int i = 0; i < t.size(); i++){
        cout << t[i] << " ";
    }
    cout << "\n";
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t;
    cin >> t;
    while(t--) {
        solve();
    }
}

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