Submission #724113

# Submission time Handle Problem Language Result Execution time Memory
724113 2023-04-14T18:04:34 Z Denkata Bootfall (IZhO17_bootfall) C++14
0 / 100
1 ms 388 KB
#include<bits/stdc++.h>
using namespace std;
const int maxn = 503;
bitset <250006> ans;
bitset <250006> tek;
bitset <250006> newtek;
int i,j,p,q,n,m,k,sum;
int a[maxn];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    for(i=1; i<=n; i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    for(i=2;i<=n;i++)
    {
        if(a[i]%2!=a[i-1]%2)
        {
            cout<<0<<endl;
            return 0;
        }
    }
    for(i=0;i<=sum;i++)
        ans[i]=1;
    tek.set(0);
    for(i=1;i<=n;i++)
    {
        ///bez i
        tek[0]=1;
        for(j=1;j<=n;j++)
        {
            if(j==i)continue;
            tek|=(tek<<(2*a[j]));

        }
        tek=(tek<<(a[i]));
        for(j=0;j<=sum;j++)
            ans[j]=ans[j]&tek[j],tek[j]=0;
    }
    int br = 0;
    for(i=0;i<sum;i++)
        if(ans[i])br++;
    cout<<br<<endl;
    for(i=sum;i>=0;i--)
    {
        if(ans[i])
            cout<<sum-i<<" ";
    }
    return 0;
}
/**
4
1 3 1 5
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 388 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 388 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 388 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 388 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 388 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 388 KB Output isn't correct
4 Halted 0 ms 0 KB -