-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintro8.cpp
47 lines (41 loc) · 800 Bytes
/
intro8.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
#include <iostream>
#include <unordered_set>
using namespace std;
int main(void) {
long long n;
cin >> n;
long long s = n * (n + 1) / 2;
if (s % 2 == 1) {
cout << "NO" << endl;
} else {
s /= 2;
cout << "YES" << endl;
unordered_set<long long> lhs;
unordered_set<long long> rhs;
int k = n;
while (true) {
if (s > k) {
lhs.insert(k);
s -= k;
k -= 1;
} else {
break;
}
}
lhs.insert(s);
for (int i = 1; i <= n; ++i) {
if (lhs.find(i) == lhs.end())
rhs.insert(i);
}
cout << lhs.size() << endl;
for (auto x : lhs) {
cout << x << " ";
}
cout << endl << rhs.size() << endl;
for (auto x : rhs) {
cout << x << " ";
}
}
cout << endl;
return 0;
}