-
Notifications
You must be signed in to change notification settings - Fork 187
/
1092.cc
44 lines (41 loc) · 835 Bytes
/
1092.cc
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
// https://cses.fi/problemset/task/1092/
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
ll n;
cin >> n;
ll t = n * (n + 1) / 2;
if (t % 2) cout << "NO\n";
else {
t /= 2;
vector<int> a;
ll s = 0;
ll e = 0;
ll i = n;
while (true) {
a.push_back(i);
s += i--;
e = t - s;
if (!e) break;
if (e <= i) {
a.push_back(e);
break;
}
}
cout << "YES\n" << a.size() << endl;
for (int j = 0; j < a.size(); j++) {
cout << a[j];
if (j < a.size() - 1) cout << " ";
}
cout << endl;
cout << n - a.size() << endl;
for (ll j = i; j > 0; j--) {
if (j == e) continue;
cout << j;
if ((e != 1 && j > 1) || (e == 1 && j > 2)) cout << " ";
}
cout << endl;
}
}