/ SeriousOJ /

Record Detail

Accepted


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

Code

/*
    JAI JAGANNATH!
*/
//@Author : zanj0

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

template <class T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;


#define ff first
#define ss second
#define pb push_back
#define MOD 1000000007
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)
#define endl "\n"
#define timetaken cerr << "Time : " << 1000 * (long double)clock() / (long double)CLOCKS_PER_SEC << "ms\n"

typedef long long int lli;

void zanj0()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
}
void Solve()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
        v[i] = i;
    if (n % 2 == 0)
    {
        
        

        for (int i = 1; i < n; i += 2)
            swap(v[i], v[i - 1]);
        for (auto &it : v)
        {
            cout << (it + 1) << " ";
        }
        cout << endl;
    }
    else
    {

        for (int i = 1; i < n - 3; i += 2)
            swap(v[i], v[i - 1]);

        swap(v[n - 1], v[n - 3]);
        swap(v[n - 2], v[n - 3]);
        for (auto &it : v)
        {
            cout << (it + 1) << " ";
        }
        cout << endl;
    }
}
int32_t main()
{
    zanj0();
    w(t) Solve();
    timetaken;
    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:34:33
Judged At
2025-07-14 15:34:33
Judged By
Score
100
Total Time
2ms
Peak Memory
532.0 KiB