Code
#include <bits/stdc++.h>
using namespace std;
void solve(){
int n;
cin >> n;
int vis[n+1];
memset(vis,0,sizeof(vis));
vector<int> ans(n);
for(int i = 1 ; i <= n ; i++) ans[i-1] = i;
for(int i = 0 ; i < n - 1; i += 2){
swap(ans[i],ans[i+1]);
}
if(ans[n-1] == n) swap(ans[n-1],ans[n-2]);
for(int i = 0 ; i < n ; i++) cout << ans[i] << " ";
cout << endl;
}
int main()
{
int t = 1;
cin >> t;
while(t--) solve();
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 15:56:42
- Judged At
- 2025-07-14 15:56:42
- Judged By
- Score
- 100
- Total Time
- 2ms
- Peak Memory
- 532.0 KiB