-
Notifications
You must be signed in to change notification settings - Fork 0
/
Two_Sets.cpp
113 lines (88 loc) · 1.69 KB
/
Two_Sets.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include <bits/stdc++.h>
using namespace std;
long long ss(int a)
{
if (a < 1)
return 0;
long long res = 1;
for (int i = 0; i < 8 * sizeof(int); i++)
{
long long cur = 1 << i;
if (cur > a)
break;
res = cur;
}
return res;
}
void solve()
{
long long a, b;
cin >> a >> b;
long long res = 0;
res += max(a - 1, b - 1) * max(a - 1, b - 1);
long long mx = max(a - 1, b - 1);
if (mx % 2 == 0)
{
if (mx == a - 1)
{
res = mx * mx + b;
}
else
{
res = (mx + 1) * (mx + 1) - (a - 1);
}
}
else
{
if (mx == a - 1)
{
res = (mx + 1) * (mx + 1) - (b - 1);
}
else
{
res = (mx * mx) + a;
}
}
cout << res << '\n';
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long n;
cin >> n;
long long sum = (n * (n + 1)) / 2;
if(sum % 2 == 1)
{
cout << "NO\n";
} else {
vector<int> v1;
vector<int> v2;
long long rs = sum / 2;
cout << "YES\n";
for(int i = n; i >= 1; i--)
{
if(i <= rs)
{
v1.push_back(i);
rs -= i;
} else {
v2.push_back(i);
}
}
cout << v1.size() << '\n';
for(auto i : v1)
{
cout << i << ' ';
}
cout << '\n';
cout << v2.size() << '\n';
for(auto i : v2)
{
cout << i << ' ';
}
cout << '\n';
}
return 0;
}