/ SeriousOJ /

Record Detail

Accepted


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

Code

#pragma GCC optimize("O3", "inline")
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;
#define pb push_back
#define ub upper_bound
#define INF 1e18 + 100

struct Compare{
    bool operator()(const ll a, const ll b) const {
        return a < b;
    }
};

vector<int> solve()
{
    int n;
    cin >> n;
    vector<int> ansa(n);
    for(int i = 0; i < n; i++) {
        if(i % 2 == 0) ansa[i] = i + 2;
        else ansa[i] = i;
    }
    if(n % 2){
        ansa[n - 2] = n;
        ansa[n - 1] = n - 2;
    }
    return ansa;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while(t--)
    {
        vector<int> ansa = solve();
        for(int x: ansa) cout << x << ' ';
        cout << '\n';
    }
    return 0;
}

Information

Submit By
Type
Pretest
Problem
P1210 A. Smallest Permutation
Language
C++17 (G++ 13.2.0)
Submit At
2025-07-14 15:36:15
Judged At
2025-07-14 15:36:15
Judged By
Score
10
Total Time
4ms
Peak Memory
532.0 KiB