Code
#include <iostream>
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
int N;
cin >> N;
if (N % 2 == 0) {
for (int i = 1; i <= N; i += 2) {
cout << i + 1 << " " << i << " ";
}
} else {
cout << "2 3 1 ";
for (int i = 4; i <= N; i += 2) {
if (i + 1 <= N)
cout << i + 1 << " " << i << " ";
else
cout << i << " ";
}
}
cout << endl;
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1210 A. Smallest Permutation
- Contest
- Educational Round 1
- Language
- C++11 (G++ 13.2.0)
- Submit At
- 2025-07-14 15:54:23
- Judged At
- 2025-07-14 15:54:23
- Judged By
- Score
- 0
- Total Time
- 2ms
- Peak Memory
- 532.0 KiB