# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
472791 | ogibogi2004 | Bootfall (IZhO17_bootfall) | C++14 | 11 ms | 588 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |