/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 3ms 2.77 MiB
#2 Accepted 4ms 2.785 MiB

Code

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define       ll           long long
#define       dub          double
#define       ull          unsigned long long
#define       CY           cout << "YES\n"
#define       CN           cout << "NO\n"
#define       pb           push_back
#define       eb           emplace_back
#define       ft           first
#define       sd           second
#define       srt(v)       sort(v.begin(), v.end())
#define       csrt(v)      sort(v.begin(), v.end(), cmp)
#define       rsrt(v)      sort(v.rbegin(), v.rend())
#define       pll          pair<ll, ll>
#define       vll          vector<pll>
#define       mod1         1000000000+7 // 10^9 + 7
#define       pbds         tree<pair<ll, ll>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>
const ll mod = 1000000007;
const ll inf = 9000000000000000000;

bool cmp(const pair<string, pair<string, ll>> &a, const pair<string, pair<string, ll>> &b)
{
    if(a.sd.ft != b.sd.ft) return a.sd.ft < b.sd.ft;
    if(a.ft != b.ft) return a.ft < b.ft;
    return a.sd.sd > b.sd.sd;
}

const ll mx = 1e5+15;
vll adj[mx];

void solve(int cs)
{
    ll n;
    cin >> n;
    ll a[n+5];
    if(n == 3){
        cout << "2 3 1\n";
        return;
    }
    for(ll i=1; i<=n; i++){
        a[i] = i;
    }
    for(ll i=1; i<=n; i+=2){
        swap(a[i], a[i+1]);
    }
    if(n & 1) a[n] = n, swap(a[n-1], a[n]);
    for(ll i=1; i<=n; i++) cout << a[i] << " ";
    cout << endl;
}

int main() {

        //ios::sync_with_stdio(false);
        //cin.tie(nullptr);

        int tc=1, cnt=1;
        cin >> tc;
        while (tc--){
            solve(cnt);
            cnt++;
        }


 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:20
Judged At
2025-07-14 15:40:20
Judged By
Score
100
Total Time
4ms
Peak Memory
2.785 MiB