/ SeriousOJ /

Record Detail

Accepted


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

Code

/*
 * Name : Md. Fahmidur Rahman Nafi
 * Date : 2025-07-14   Time : 20:31:54
 */

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define ld long double
#define ull unsigned long long
#define lcm(a,b) ((a*b)/__gcd(a,b))
#define debug(x) cout << "Debug : " << x << endl;
const double PI = 2 * acos(0.0);
const int MOD = 1000000007;

void solve(){
    int n;
    cin >> n;
    vector <int> A, B;
    for (int i = 2; i <= n; i += 2)
        A.push_back(i);
    for (int i = 1; i <= n; i+= 2)
        B.push_back(i);
    
    if (n % 2 == 0){
        for (int i = 0; i < n / 2; i++){
            cout << A[i] << ' ';
            cout << B[i] << ' ';
        }
    }
    else{
        for (int i = 0; i < min(A.size(), B.size()) - 1; i++){
            cout << A[i] << ' ';
            cout << B[i] << ' ';
        }
        cout << n - 1 << ' ' << n << ' ' << n - 2;
    }
    cout << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;

    while(t--){
        solve();
    }
}

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