/ 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;
#define ll long long
#define all(x) (x).begin(), (x).end()
#define f(i, n) for (int i = 0; i < n; i++)
#define trace(x) cerr << #x << ": " << x << '\n'

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        // 1 2 3 4 5 6 7
        // 2 1 4 3 6 7 5
        if (n % 2 == 0)
        {
            for (int i = 1; i <= n; i += 2)
                cout << i + 1 << ' ' << i << ' ';
        }
        else
        {
            for (int i = 1; i <= n - 3; i += 2)
                cout << i + 1 << ' ' << i << ' ';
            cout << n - 1 << ' ' << n << ' ' << n - 2 << ' ';
        }
        cout << endl;
    }

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