/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 2ms 564.0 KiB

Code

// Bismillahir Rahmanir Raheem
#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;

typedef long long ll;
typedef double dl;
typedef tree< ll, null_type, greater_equal<ll>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))
#define u_b upper_bound
#define l_b lower_bound
#define setpre(n) fixed<<setprecision(n)
#define MOD 1000000007
const double eps = 1e-9;
const double PI = acos(-1);
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t; cin >> t;
    while(t--){
        int n; cin >> n;
        if(n & 1){
            for(int i = 1; i <= n - 3; ++i){
                if(i & 1) cout << i + 1 << ' ';
                else cout << i - 1 << ' ';
            }
            cout << n - 1 << ' ' << n << ' ' << n - 2 << '\n';
        }
        else{
            for(int i = 1; i <= n; ++i){
                if(i & 1) cout << i + 1 << ' ';
                else cout << i - 1 << ' ';     
            }
            cout << '\n';
        }
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1210 A. Smallest Permutation
Language
C++17 (G++ 13.2.0)
Submit At
2025-07-15 07:35:44
Judged At
2025-07-15 07:35:44
Judged By
Score
100
Total Time
2ms
Peak Memory
564.0 KiB