Submission #878230

# Submission time Handle Problem Language Result Execution time Memory
878230 2023-11-24T07:33:52 Z alexdd Bootfall (IZhO17_bootfall) C++17
44 / 100
1000 ms 1364 KB
#pragma GCC optimize("O3,unroll-loops")
#include<bits/stdc++.h>
using namespace std;
int n,tot;
int a[505];
bitset<500005> dp;
int variante[500005],cntv;
int newv[500005],cntnew;
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]%2!=a[1]%2)
        {
            cout<<0;
            return 0;
        }
        tot+=a[i];
    }
    if(tot%2==1)
    {
        cout<<0;
        return 0;
    }
    for(int i=1;i<=tot;i++)
        if(i%2==a[1]%2)
            variante[++cntv]=i;
    for(int i=0;i<=n;i++)
    {
        dp.reset();
        dp[0]=1;
        for(int j=1;j<=n;j++)
        {
            if(i!=j)
                dp |= (dp<<a[j]);
        }
        if(i==0)
        {
            if(dp[tot/2]==0)
            {
                cout<<0;
                return 0;
            }
            continue;
        }
        cntnew=0;
        for(int j=1;j<=cntv;j++)
        {
            int x = variante[j];
            if((tot-a[i]+x)%2==0 && dp[(tot-a[i]+x)/2])
                newv[++cntnew] = x;
            ///tot - a[i] + x
        }
        cntv=cntnew;
        for(int j=1;j<=cntnew;j++)
            variante[j] = newv[j];
    }
    cout<<cntv<<"\n";
    for(int i=1;i<=cntv;i++)
        cout<<variante[i]<<" ";
    return 0;
}
/**
3
2 2 2
*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 9 ms 620 KB Output is correct
11 Correct 8 ms 604 KB Output is correct
12 Correct 8 ms 600 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 7 ms 652 KB Output is correct
15 Correct 7 ms 652 KB Output is correct
16 Correct 8 ms 600 KB Output is correct
17 Correct 3 ms 856 KB Output is correct
18 Correct 5 ms 604 KB Output is correct
19 Correct 6 ms 604 KB Output is correct
20 Correct 8 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 9 ms 620 KB Output is correct
11 Correct 8 ms 604 KB Output is correct
12 Correct 8 ms 600 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 7 ms 652 KB Output is correct
15 Correct 7 ms 652 KB Output is correct
16 Correct 8 ms 600 KB Output is correct
17 Correct 3 ms 856 KB Output is correct
18 Correct 5 ms 604 KB Output is correct
19 Correct 6 ms 604 KB Output is correct
20 Correct 8 ms 604 KB Output is correct
21 Correct 33 ms 604 KB Output is correct
22 Correct 44 ms 600 KB Output is correct
23 Correct 21 ms 604 KB Output is correct
24 Correct 74 ms 604 KB Output is correct
25 Correct 70 ms 680 KB Output is correct
26 Correct 80 ms 664 KB Output is correct
27 Correct 83 ms 652 KB Output is correct
28 Correct 81 ms 604 KB Output is correct
29 Correct 80 ms 604 KB Output is correct
30 Correct 0 ms 344 KB Output is correct
31 Correct 81 ms 680 KB Output is correct
32 Correct 79 ms 644 KB Output is correct
33 Correct 79 ms 604 KB Output is correct
34 Correct 78 ms 652 KB Output is correct
35 Correct 79 ms 656 KB Output is correct
36 Correct 78 ms 656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 9 ms 620 KB Output is correct
11 Correct 8 ms 604 KB Output is correct
12 Correct 8 ms 600 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 7 ms 652 KB Output is correct
15 Correct 7 ms 652 KB Output is correct
16 Correct 8 ms 600 KB Output is correct
17 Correct 3 ms 856 KB Output is correct
18 Correct 5 ms 604 KB Output is correct
19 Correct 6 ms 604 KB Output is correct
20 Correct 8 ms 604 KB Output is correct
21 Correct 33 ms 604 KB Output is correct
22 Correct 44 ms 600 KB Output is correct
23 Correct 21 ms 604 KB Output is correct
24 Correct 74 ms 604 KB Output is correct
25 Correct 70 ms 680 KB Output is correct
26 Correct 80 ms 664 KB Output is correct
27 Correct 83 ms 652 KB Output is correct
28 Correct 81 ms 604 KB Output is correct
29 Correct 80 ms 604 KB Output is correct
30 Correct 0 ms 344 KB Output is correct
31 Correct 81 ms 680 KB Output is correct
32 Correct 79 ms 644 KB Output is correct
33 Correct 79 ms 604 KB Output is correct
34 Correct 78 ms 652 KB Output is correct
35 Correct 79 ms 656 KB Output is correct
36 Correct 78 ms 656 KB Output is correct
37 Correct 314 ms 708 KB Output is correct
38 Correct 313 ms 600 KB Output is correct
39 Correct 480 ms 748 KB Output is correct
40 Correct 588 ms 760 KB Output is correct
41 Correct 580 ms 600 KB Output is correct
42 Correct 494 ms 848 KB Output is correct
43 Correct 495 ms 860 KB Output is correct
44 Correct 506 ms 856 KB Output is correct
45 Correct 514 ms 860 KB Output is correct
46 Correct 566 ms 604 KB Output is correct
47 Correct 512 ms 756 KB Output is correct
48 Correct 506 ms 836 KB Output is correct
49 Correct 489 ms 856 KB Output is correct
50 Correct 512 ms 760 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 608 ms 884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 9 ms 620 KB Output is correct
11 Correct 8 ms 604 KB Output is correct
12 Correct 8 ms 600 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 7 ms 652 KB Output is correct
15 Correct 7 ms 652 KB Output is correct
16 Correct 8 ms 600 KB Output is correct
17 Correct 3 ms 856 KB Output is correct
18 Correct 5 ms 604 KB Output is correct
19 Correct 6 ms 604 KB Output is correct
20 Correct 8 ms 604 KB Output is correct
21 Correct 33 ms 604 KB Output is correct
22 Correct 44 ms 600 KB Output is correct
23 Correct 21 ms 604 KB Output is correct
24 Correct 74 ms 604 KB Output is correct
25 Correct 70 ms 680 KB Output is correct
26 Correct 80 ms 664 KB Output is correct
27 Correct 83 ms 652 KB Output is correct
28 Correct 81 ms 604 KB Output is correct
29 Correct 80 ms 604 KB Output is correct
30 Correct 0 ms 344 KB Output is correct
31 Correct 81 ms 680 KB Output is correct
32 Correct 79 ms 644 KB Output is correct
33 Correct 79 ms 604 KB Output is correct
34 Correct 78 ms 652 KB Output is correct
35 Correct 79 ms 656 KB Output is correct
36 Correct 78 ms 656 KB Output is correct
37 Correct 314 ms 708 KB Output is correct
38 Correct 313 ms 600 KB Output is correct
39 Correct 480 ms 748 KB Output is correct
40 Correct 588 ms 760 KB Output is correct
41 Correct 580 ms 600 KB Output is correct
42 Correct 494 ms 848 KB Output is correct
43 Correct 495 ms 860 KB Output is correct
44 Correct 506 ms 856 KB Output is correct
45 Correct 514 ms 860 KB Output is correct
46 Correct 566 ms 604 KB Output is correct
47 Correct 512 ms 756 KB Output is correct
48 Correct 506 ms 836 KB Output is correct
49 Correct 489 ms 856 KB Output is correct
50 Correct 512 ms 760 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 608 ms 884 KB Output is correct
53 Correct 719 ms 804 KB Output is correct
54 Correct 967 ms 1104 KB Output is correct
55 Execution timed out 1014 ms 1364 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 9 ms 620 KB Output is correct
11 Correct 8 ms 604 KB Output is correct
12 Correct 8 ms 600 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 7 ms 652 KB Output is correct
15 Correct 7 ms 652 KB Output is correct
16 Correct 8 ms 600 KB Output is correct
17 Correct 3 ms 856 KB Output is correct
18 Correct 5 ms 604 KB Output is correct
19 Correct 6 ms 604 KB Output is correct
20 Correct 8 ms 604 KB Output is correct
21 Correct 33 ms 604 KB Output is correct
22 Correct 44 ms 600 KB Output is correct
23 Correct 21 ms 604 KB Output is correct
24 Correct 74 ms 604 KB Output is correct
25 Correct 70 ms 680 KB Output is correct
26 Correct 80 ms 664 KB Output is correct
27 Correct 83 ms 652 KB Output is correct
28 Correct 81 ms 604 KB Output is correct
29 Correct 80 ms 604 KB Output is correct
30 Correct 0 ms 344 KB Output is correct
31 Correct 81 ms 680 KB Output is correct
32 Correct 79 ms 644 KB Output is correct
33 Correct 79 ms 604 KB Output is correct
34 Correct 78 ms 652 KB Output is correct
35 Correct 79 ms 656 KB Output is correct
36 Correct 78 ms 656 KB Output is correct
37 Correct 314 ms 708 KB Output is correct
38 Correct 313 ms 600 KB Output is correct
39 Correct 480 ms 748 KB Output is correct
40 Correct 588 ms 760 KB Output is correct
41 Correct 580 ms 600 KB Output is correct
42 Correct 494 ms 848 KB Output is correct
43 Correct 495 ms 860 KB Output is correct
44 Correct 506 ms 856 KB Output is correct
45 Correct 514 ms 860 KB Output is correct
46 Correct 566 ms 604 KB Output is correct
47 Correct 512 ms 756 KB Output is correct
48 Correct 506 ms 836 KB Output is correct
49 Correct 489 ms 856 KB Output is correct
50 Correct 512 ms 760 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 608 ms 884 KB Output is correct
53 Correct 719 ms 804 KB Output is correct
54 Correct 967 ms 1104 KB Output is correct
55 Execution timed out 1014 ms 1364 KB Time limit exceeded
56 Halted 0 ms 0 KB -