/ 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;
const int N = 1e5;
const int Prime = 1e9+7;
const int Base = 251;


//...................................................................//
#define endl                '\n'
#define Int                 long long int
#define gcd(x, y)           (__gcd(x, y))
#define lcm(x, y)           ((x/gcd(x, y))*y)
#define rand(x, y)          rand()%(y-x+1)+x
#define pow2(x)             (1<<x)
#define pi                  3.141592653589793
#define decimal(x, y)       fixed<<setprecision(x)<<y
#define unsync              ios_base::sync_with_stdio(0); cin.tie(0);
#define TxtI                freopen("input.txt","r",stdin);
#define TxtO                freopen("output.txt","w",stdout);
//...................................................................//


int main()
{
    //srand(time(0));
    //TxtI TxtO
    unsync

    int t;
    
    cin >> t;
    
    while(t--)
    {
        Int n;
        vector<Int> vec;

        cin >> n;

        for(int i=1; i<=n/2; i++)
        {
            vec.push_back(2*i);
            vec.push_back(2*i-1);
        }

        if(n%2)
        {
            vec.push_back(n);
            swap(vec[n-1], vec[n-2]);
        }

        for(int i=0; i<vec.size(); i++) cout << vec[i] << ' ';
        cout << endl;
    }
}

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