Code
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
int t;
cin >> t;
while (t--){
ll n;
cin >> n;
if (n & 1){
if (n == 3){
cout << "2 3 1\n";
continue;
}
cout << "2 1 ";
for (int i = 4; i < n - 1; i += 2){
cout << i << " " << i - 1 << " ";
}
cout << n - 1 << " " << n << " " << n - 2 << endl;
} else {
for (int i = 2; i <= n; i += 2){
cout << i << " " << i - 1 << " ";
}
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:52:15
- Judged At
- 2025-07-14 15:52:15
- Judged By
- Score
- 100
- Total Time
- 4ms
- Peak Memory
- 532.0 KiB