Skip to content

Instantly share code, notes, and snippets.

@enzerr
Created April 22, 2023 19:34
Show Gist options
  • Save enzerr/9c1b017940050042705f75fdbbaadd5f to your computer and use it in GitHub Desktop.
Save enzerr/9c1b017940050042705f75fdbbaadd5f to your computer and use it in GitHub Desktop.
#include<bits/stdc++.h>
using namespace std;
#define int long long
vector<int> ans1, ans2;
int32_t main(){
ios::sync_with_stdio(false);
int n; cin >> n;
int sum = (n*n+n)/2;
if(sum%2) {cout << "NO\n"; return 0;}
sum/=2;
for(int i = n; i >= 1; i--){
if(i<=sum) sum-=i, ans1.push_back(i);
else ans2.push_back(i);
}
cout << "YES\n";
cout << ans1.size() << '\n';
reverse(ans1.begin(), ans1.end());
for(int x : ans1) cout << x << " ";
cout << '\n';
cout << ans2.size() << '\n';
reverse(ans2.begin(), ans2.end());
for(int x : ans2) cout << x << " ";
cout << '\n';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment