Code
#include <bits/stdc++.h>
using namespace std;
void solve(int cs) {
int n;
cin >> n;
vector<int> a(n);
iota(a.begin(), a.end(), 1);
for (int i = 1; i < n; i += 2) {
if (a[i] == i + 1) swap(a[i], a[i - 1]);
}
if (a.back() == n) swap(a.back(), a[n - 2]);
for (int i = 0; i < n; i++) {
cout << a[i] << " \n"[i + 1 == n];
}
}
int32_t main() {
cin.tie(0) -> sync_with_stdio(0);
int t = 1;
cin >> t;
for (int i = 1; i <= t; i++) {
solve(i);
}
return 0;
}
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 16:10:07
- Judged At
- 2025-07-14 16:10:07
- Judged By
- Score
- 100
- Total Time
- 2ms
- Peak Memory
- 532.0 KiB