Code
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
int main ()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int t; cin>>t;
while(t--)
{
int n; cin>>n;
if(n%2==0)
{
for(int i=1; i<=n; i++)
{
if(i%2!=0)
cout<<i+1<<" ";
else
cout<<i-1<<" ";
}
cout<<endl;
}
else
{
for(int i=1; i<=n-3; i++)
{
if(i%2!=0)
cout<<i+1<<" ";
else
cout<<i-1<<" ";
}
cout<<n-1<<" "<<n<<" "<<n-2<<endl;
}
}
cout<<endl;
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:50:03
- Judged At
- 2025-07-14 15:50:03
- Judged By
- Score
- 100
- Total Time
- 2ms
- Peak Memory
- 536.0 KiB