Submission #172909

#TimeUsernameProblemLanguageResultExecution timeMemory
172909LinusTorvaldsFanBootfall (IZhO17_bootfall)C++14
44 / 100
1073 ms7684 KiB
#include <bits/stdc++.h> using namespace std; const int maxn=351; const int maxc=501; const int maxw=maxc*maxn; bitset<maxn*maxc>available[maxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin>>n; vector<int>a(n); int sum=0; for(int i=0;i<n;i++) { cin>>a[i]; sum+=a[i]; } for(int i=0;i<=n;i++){ available[i][0]=true; for(int j=0;j<n;j++){ if(i==j)continue; available[i]|=available[i]<<a[j]; } } if(sum&1){ cout<<0; return 0; } if(!available[n][sum>>1]){ cout<<0; return 0; } for(int i=0;i<n;i++){ if((sum-a[i] & 1) != ((sum-a[0])&1)){ cout<<0; return 0; } } vector<int>ans; for(int x=(sum-a[0])&1;x<=maxw;x+=2){ bool ok=true; for(int i=0;i<n;i++){ int nsum=sum-a[i]+x; if(!available[i][nsum>>1]){ ok=false; break; } } if(ok){ ans.push_back(x); } } cout<<ans.size()<<endl; for(auto x:ans)cout<<x<<" "; return 0; }

Compilation message (stderr)

bootfall.cpp: In function 'int main()':
bootfall.cpp:40:10: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   if((sum-a[i] & 1) != ((sum-a[0])&1)){
#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...