Submission #1055020

#TimeUsernameProblemLanguageResultExecution timeMemory
1055020Khanhcsp2Bootfall (IZhO17_bootfall)C++14
65 / 100
1093 ms856 KiB
#include<bits/stdc++.h> #define el '\n' #define fi first #define sc second #define int ll #define pii pair<int, int> #define all(v) v.begin(), v.end() using namespace std; using ll=long long; using ull=unsigned long long; using ld=long double; const int mod=1e9+7; const int N=511; int n, a[N], sum; bitset<N*N> bs, cur, s1, s2; void sol() { cin >> n; for(int i=1;i<=n;i++) cin >> a[i]; bs&=0; bs[0]=1; for(int i=1;i<=n;i++) { bs|=bs<<(a[i]); sum+=a[i]; } if(sum&1 || bs[sum/2]==0) { cout << 0 << el; return; } int ch1=1, ch2=1; s1.set(); s2.set(); s2[0]=0; for(int i=1;i<=n;i++) { cur&=0; cur[0]=1; for(int j=1;j<=n;j++) if(j!=i) cur|=(cur<<(a[j])); int ss=sum-a[i]; if(ss%2==0) { s2&=(cur>>(ss/2)); if(ch1) { s1&=0; ch1=0; } } else { s1&=(cur>>(ss/2+1)); if(ch2) { s2&=0; ch2=0; } } } cout << s1.count()+s2.count() << el; for(int i=0;i<N*N;i++) { if(s2[i]) cout << i*2 << el; if(s1[i]) cout << i*2+1 << el; } } signed main() { // freopen("divisor.INP", "r", stdin); // freopen("divisor.OUT", "w", stdout); ios_base::sync_with_stdio(0); cin.tie(0); int t=1; //cin >> t; while(t--) { sol(); } }
#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...