forked from Sam071100/CodeForces-Solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPretty Permutations.cpp
More file actions
39 lines (36 loc) · 810 Bytes
/
Pretty Permutations.cpp
File metadata and controls
39 lines (36 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include<bits/stdc++.h>
using namespace std;
#define t1 int t; cin >>t
#define n1 int n; cin >>n
#define fr for(int i=1;i<=n-1;i++)
int main(){
t1;
while(t--){
n1;
if(n%2!=0){
cout<<3<<" "<<1<<" "<<2<<" ";
for(int i=4;i<=n;i++){
if(i%2==0){
cout<<i+1<<" ";
}
else{
cout<<i-1<<" ";
}
}
cout<<"\n";
}
else{
fr{
if(i%2==0){
cout<<i-1<<" ";
}
else{
cout<<i+1<<" ";
}
}
cout<<n-1<<" ";
cout<<"\n";
}
}
return 0;
}