Submission #472791

#TimeUsernameProblemLanguageResultExecution timeMemory
472791ogibogi2004Bootfall (IZhO17_bootfall)C++14
0 / 100
11 ms588 KiB
#include<bits/stdc++.h> using namespace std; const int MAXN=512; int n,a[MAXN],sum=0; bitset<2*MAXN*MAXN>b1,b2,b3,b4; int main() { cin>>n; for(int i=1;i<=n;i++){cin>>a[i];sum+=a[i];} for(int i=0;i<MAXN*MAXN;i++)b1[i]=1; b1=0; b1[MAXN*MAXN]=1; for(int i=1;i<=n;i++) { b2=0; for(int j=0;j<2*MAXN*MAXN;j++) { if(b1[j]==0)continue; b2[j-a[i]]=1; b2[j+a[i]]=1; } b1=b2; } if(b1[MAXN*MAXN]==0) { cout<<"0\n"; return 0; } b2=0; for(int i=0;i<2*MAXN*MAXN;i++) { if(b1[i]==0)continue; b2[abs(MAXN*MAXN-i)]=1; } b1=b2; for(int i=0;i<MAXN*MAXN;i++) { if(b1[i])cout<<i<<" "; } cout<<endl; cout<<endl; for(int i=0;i<MAXN*MAXN;i++)b3[i]=1; for(int i=1;i<=n;i++) { b4=0; for(int j=0;j<MAXN*MAXN;j++) { if(b1[j]==0)continue; int t=abs(j-a[i]); b4[t]=1; } for(int j=0;j<MAXN*MAXN;j++) { if(b4[j])cout<<j<<" "; } cout<<endl; b3&=b4; for(int j=0;j<MAXN*MAXN;j++) { if(b3[j])cout<<j<<" "; } cout<<endl; cout<<endl<<endl; } vector<int>ans; for(int i=1;i<=sum;i++) { if(b3[i]==1)ans.push_back(i); } cout<<ans.size()<<endl; for(auto xd:ans) { cout<<xd<<" "; } cout<<endl; if(ans.size()>n)assert(false); return 0; }

Compilation message (stderr)

bootfall.cpp: In function 'int main()':
bootfall.cpp:77:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   77 |     if(ans.size()>n)assert(false);
      |        ~~~~~~~~~~^~
#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...