Submission #1126609

#TimeUsernameProblemLanguageResultExecution timeMemory
1126609brover29Bootfall (IZhO17_bootfall)C++20
6 / 100
1095 ms396 KiB
#include <bits/stdc++.h> //qwerty47924692 using namespace std; using ll = long long; const ll N=2e5+29; const string br="617283"; ll n,a[N],ok=0; set<ll>s; set<ll>x; void f(ll x,ll i,ll s1=0,ll s2=0){ if(x==n){ if(i==n+1&&s1==s2){ ok=1; } s.insert(abs(s1-s2)); return; } x++; if(x==i){ f(x,i,s1,s2); return; } f(x,i,s1+a[x],s2); f(x,i,s1,s2+a[x]); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin>>n; for(ll i=1;i<=n;i++){ cin>>a[i]; } f(0,1); swap(s,x); s.clear(); f(0,n+1); if(!ok){ cout<<0; return 0; } for(ll i=2;i<=n;i++){ f(0,i); for(auto it=x.begin();it!=x.end();){ if(s.find(*it)==s.end()){ it=x.erase(it); }else it++; } s.clear(); } cout<<x.size()<<'\n'; for(ll i:x){ cout<<i<<' '; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...