Code
#include <iostream>
#include <vector>
using namespace std;
void solve() {
int n;
cin >> n;
if (n % 2 == 0) {
for (int i = 1; i <= n; i += 2) {
cout << i+1 << " " << i << " ";
}
} else {
for (int i = 1; i <= n-3; i += 2) {
cout << i+1 << " " << i << " ";
}
cout << n-1 << " " << n << " " << n-2;
}
cout << endl;
}
int main() {
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1210 A. Smallest Permutation
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2025-08-30 19:19:33
- Judged At
- 2025-08-30 19:19:33
- Judged By
- Score
- 100
- Total Time
- 2ms
- Peak Memory
- 532.0 KiB