/ SeriousOJ /

Record Detail

Accepted


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

Code

#include <bits/stdc++.h>
#define all(a) (a).begin() (a).end()
using namespace std;

void solve() {
    int n; cin >> n;
    int p[n];
    iota(p, p+n, 0);
    for (int i = 0; i+1 < n; i += 2)
        swap(p[i], p[i+1]);
    if (n & 1)
        swap(p[n-1], p[n-2]);
    for (int x : p) cout << x+1 << " ";
    cout << "\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.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 17:08:39
Judged At
2025-07-14 17:08:39
Judged By
Score
100
Total Time
2ms
Peak Memory
532.0 KiB