Code
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
int n;
cin>>n;
vector<int> ans(n);
for(int i=0;i<n;i++)
ans[i]=i+1;
for(int i=0;i+1<n;i=i+2)
swap(ans[i],ans[i+1]);
if(n%2)
swap(ans[n-1],ans[n-2]);
for(auto c:ans)
cout<<c<<' ';
cout<<endl;
}
}
Information
- Submit By
- Type
- Submission
- Problem
- P1210 A. Smallest Permutation
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2025-09-01 03:54:35
- Judged At
- 2025-09-01 03:54:35
- Judged By
- Score
- 100
- Total Time
- 2ms
- Peak Memory
- 532.0 KiB