Code
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve();
int main() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
int tc; cin >> tc;
for (int tt = 0; tt < tc; tt++) solve();
return 0;
}
void solve() {
int n; cin >> n;
vector<int> ans(n);
iota(ans.begin(), ans.end(), 1);
for (int i = 0; i + 1 < n; i += 2) swap(ans[i], ans[i + 1]);
if (n & 1) swap(ans[n - 1], ans[n - 2]);
for (int i = 0; i < n; i++) {
cout << ans[i] << (i == n - 1 ? "\n" : " ");
}
}
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:42:57
- Judged At
- 2025-07-14 15:42:57
- Judged By
- Score
- 100
- Total Time
- 2ms
- Peak Memory
- 532.0 KiB