-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path1343B_Balanced_Array.cpp
More file actions
63 lines (56 loc) · 1.44 KB
/
1343B_Balanced_Array.cpp
File metadata and controls
63 lines (56 loc) · 1.44 KB
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
59
60
61
62
63
#define DEBUG
#define MAXN 10000000
#include <bits/stdc++.h>
using namespace std;
int main() {
#ifdef DEBUG
freopen("in.in", "r", stdin);
#endif
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
if ((n/2)%2 == 1) {
cout << "NO" << endl;
continue;
}
cout << "YES" << endl;
// even
for (int i = 0; i < n/4; ++i) {
if (i % 2 == 0) {
if (i != 0) {
cout << i << 2 << " " << i << 8 << " ";
} else {
cout << 2 << " " << 8 << " ";
}
} else {
if (i != 1) {
cout << (i-1)/2 << 4 << " " << (i-1)/2 << 6 << " ";
} else {
cout << 4 << " " << 6 << " ";
}
}
}
// odd
for (int i = 0; i < n/4; ++i) {
if (i % 2 == 0) {
if (i != 0) {
cout << i << 1 << " " << i << 9 << " ";
} else {
cout << 1 << " " << 9 << " ";
}
} else {
if (i != 1) {
cout << (i-1)/2 << 3 << " " << (i-1)/2 << 7 << " ";
} else {
cout << 3 << " " << 7 << " ";
}
}
}
cout << endl;
}
return 0;
}