-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy path1541A.cpp
58 lines (52 loc) · 928 Bytes
/
1541A.cpp
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define debug(n) cout<<(n)<<endl;
const ll INF = 2e18 + 99;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
int n;
while(t--){
cin>>n;
bool check = false;
if(n & 1){
for(int i = 1; i <= n; i++){
check = !check;
if(i == n-2){
cout<<i+1<<" ";
continue;
}
if(i == n-1){
cout<<i+1<<" ";
continue;
}
if(i == n){
cout<<i-2<<" ";
continue;
}
if(check){
cout<<i+1<<" ";
}
else{
cout<<i-1<<" ";
}
}
}
else{
for(int i = 1; i <= n; i++){
check = !check;
if(check){
cout<<i+1<<" ";
}
else{
cout<<i-1<<" ";
}
}
}
cout<<endl;
}
}