-
Notifications
You must be signed in to change notification settings - Fork 0
/
Two Sets.cpp
51 lines (50 loc) · 1.47 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
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
while(t--){
long long n;
cin>>n;
if(((n >> 2) << 2) == n || (((n+1) >> 2) << 2) == n+1 ){
cout<<"YES"<<"\n";
long long set_sum = (n * (n+1)) >> 2;
long long x = ceil((sqrtl(8*set_sum+1) - 1)/2);
long long x_sum = (x * (x+1)) >> 1;
if(x_sum==set_sum){
cout<<x<<"\n";
for(int i=1;i<=x;i++){
cout<<i<<" ";
}
cout<<"\n";
cout<<n - x<<"\n";
for(int i=x+1;i<=n;i++){
cout<<i<<" ";
}
cout<<"\n";
}
else{
long long extra = x_sum - set_sum;
cout<<x-1<<"\n";
for(int i=1;i<=x;i++){
if(i==extra){
continue;
}
cout<<i<<" ";
}
cout<<"\n";
cout<< n -x +1<<"\n";
for(int i=x+1;i<=n;i++){
cout<<i<<" ";
}
cout<<extra<<"\n";
}
}
else{
cout<<"NO"<<"\n";
}
}
return 0;
}