Submission #878234

# Submission time Handle Problem Language Result Execution time Memory
878234 2023-11-24T07:35:53 Z alexdd Bootfall (IZhO17_bootfall) C++17
65 / 100
1000 ms 1860 KB
#pragma GCC optimize("O3,unroll-loops")
#include<iostream>
#include<bitset>
using namespace std;
int n,tot;
int a[505];
bitset<250005> dp;
int variante[250005],cntv;
int newv[250005],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 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 4 ms 344 KB Output is correct
11 Correct 4 ms 600 KB Output is correct
12 Correct 4 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 3 ms 348 KB Output is correct
15 Correct 3 ms 348 KB Output is correct
16 Correct 4 ms 348 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 3 ms 348 KB Output is correct
19 Correct 3 ms 348 KB Output is correct
20 Correct 4 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 4 ms 344 KB Output is correct
11 Correct 4 ms 600 KB Output is correct
12 Correct 4 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 3 ms 348 KB Output is correct
15 Correct 3 ms 348 KB Output is correct
16 Correct 4 ms 348 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 3 ms 348 KB Output is correct
19 Correct 3 ms 348 KB Output is correct
20 Correct 4 ms 348 KB Output is correct
21 Correct 17 ms 348 KB Output is correct
22 Correct 21 ms 348 KB Output is correct
23 Correct 10 ms 348 KB Output is correct
24 Correct 36 ms 576 KB Output is correct
25 Correct 36 ms 348 KB Output is correct
26 Correct 39 ms 588 KB Output is correct
27 Correct 41 ms 572 KB Output is correct
28 Correct 39 ms 344 KB Output is correct
29 Correct 41 ms 596 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 38 ms 348 KB Output is correct
32 Correct 38 ms 348 KB Output is correct
33 Correct 43 ms 348 KB Output is correct
34 Correct 38 ms 344 KB Output is correct
35 Correct 38 ms 348 KB Output is correct
36 Correct 38 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 4 ms 344 KB Output is correct
11 Correct 4 ms 600 KB Output is correct
12 Correct 4 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 3 ms 348 KB Output is correct
15 Correct 3 ms 348 KB Output is correct
16 Correct 4 ms 348 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 3 ms 348 KB Output is correct
19 Correct 3 ms 348 KB Output is correct
20 Correct 4 ms 348 KB Output is correct
21 Correct 17 ms 348 KB Output is correct
22 Correct 21 ms 348 KB Output is correct
23 Correct 10 ms 348 KB Output is correct
24 Correct 36 ms 576 KB Output is correct
25 Correct 36 ms 348 KB Output is correct
26 Correct 39 ms 588 KB Output is correct
27 Correct 41 ms 572 KB Output is correct
28 Correct 39 ms 344 KB Output is correct
29 Correct 41 ms 596 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 38 ms 348 KB Output is correct
32 Correct 38 ms 348 KB Output is correct
33 Correct 43 ms 348 KB Output is correct
34 Correct 38 ms 344 KB Output is correct
35 Correct 38 ms 348 KB Output is correct
36 Correct 38 ms 348 KB Output is correct
37 Correct 156 ms 624 KB Output is correct
38 Correct 156 ms 600 KB Output is correct
39 Correct 234 ms 604 KB Output is correct
40 Correct 289 ms 660 KB Output is correct
41 Correct 286 ms 680 KB Output is correct
42 Correct 269 ms 604 KB Output is correct
43 Correct 236 ms 756 KB Output is correct
44 Correct 245 ms 764 KB Output is correct
45 Correct 253 ms 852 KB Output is correct
46 Correct 282 ms 624 KB Output is correct
47 Correct 247 ms 660 KB Output is correct
48 Correct 247 ms 744 KB Output is correct
49 Correct 243 ms 728 KB Output is correct
50 Correct 256 ms 676 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 301 ms 812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 4 ms 344 KB Output is correct
11 Correct 4 ms 600 KB Output is correct
12 Correct 4 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 3 ms 348 KB Output is correct
15 Correct 3 ms 348 KB Output is correct
16 Correct 4 ms 348 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 3 ms 348 KB Output is correct
19 Correct 3 ms 348 KB Output is correct
20 Correct 4 ms 348 KB Output is correct
21 Correct 17 ms 348 KB Output is correct
22 Correct 21 ms 348 KB Output is correct
23 Correct 10 ms 348 KB Output is correct
24 Correct 36 ms 576 KB Output is correct
25 Correct 36 ms 348 KB Output is correct
26 Correct 39 ms 588 KB Output is correct
27 Correct 41 ms 572 KB Output is correct
28 Correct 39 ms 344 KB Output is correct
29 Correct 41 ms 596 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 38 ms 348 KB Output is correct
32 Correct 38 ms 348 KB Output is correct
33 Correct 43 ms 348 KB Output is correct
34 Correct 38 ms 344 KB Output is correct
35 Correct 38 ms 348 KB Output is correct
36 Correct 38 ms 348 KB Output is correct
37 Correct 156 ms 624 KB Output is correct
38 Correct 156 ms 600 KB Output is correct
39 Correct 234 ms 604 KB Output is correct
40 Correct 289 ms 660 KB Output is correct
41 Correct 286 ms 680 KB Output is correct
42 Correct 269 ms 604 KB Output is correct
43 Correct 236 ms 756 KB Output is correct
44 Correct 245 ms 764 KB Output is correct
45 Correct 253 ms 852 KB Output is correct
46 Correct 282 ms 624 KB Output is correct
47 Correct 247 ms 660 KB Output is correct
48 Correct 247 ms 744 KB Output is correct
49 Correct 243 ms 728 KB Output is correct
50 Correct 256 ms 676 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 301 ms 812 KB Output is correct
53 Correct 358 ms 716 KB Output is correct
54 Correct 489 ms 748 KB Output is correct
55 Correct 526 ms 1364 KB Output is correct
56 Correct 388 ms 756 KB Output is correct
57 Correct 503 ms 1236 KB Output is correct
58 Correct 489 ms 772 KB Output is correct
59 Correct 479 ms 832 KB Output is correct
60 Correct 0 ms 344 KB Output is correct
61 Correct 508 ms 1108 KB Output is correct
62 Correct 431 ms 1176 KB Output is correct
63 Correct 417 ms 1108 KB Output is correct
64 Correct 401 ms 1204 KB Output is correct
65 Correct 399 ms 604 KB Output is correct
66 Correct 370 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 4 ms 344 KB Output is correct
11 Correct 4 ms 600 KB Output is correct
12 Correct 4 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 3 ms 348 KB Output is correct
15 Correct 3 ms 348 KB Output is correct
16 Correct 4 ms 348 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 3 ms 348 KB Output is correct
19 Correct 3 ms 348 KB Output is correct
20 Correct 4 ms 348 KB Output is correct
21 Correct 17 ms 348 KB Output is correct
22 Correct 21 ms 348 KB Output is correct
23 Correct 10 ms 348 KB Output is correct
24 Correct 36 ms 576 KB Output is correct
25 Correct 36 ms 348 KB Output is correct
26 Correct 39 ms 588 KB Output is correct
27 Correct 41 ms 572 KB Output is correct
28 Correct 39 ms 344 KB Output is correct
29 Correct 41 ms 596 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 38 ms 348 KB Output is correct
32 Correct 38 ms 348 KB Output is correct
33 Correct 43 ms 348 KB Output is correct
34 Correct 38 ms 344 KB Output is correct
35 Correct 38 ms 348 KB Output is correct
36 Correct 38 ms 348 KB Output is correct
37 Correct 156 ms 624 KB Output is correct
38 Correct 156 ms 600 KB Output is correct
39 Correct 234 ms 604 KB Output is correct
40 Correct 289 ms 660 KB Output is correct
41 Correct 286 ms 680 KB Output is correct
42 Correct 269 ms 604 KB Output is correct
43 Correct 236 ms 756 KB Output is correct
44 Correct 245 ms 764 KB Output is correct
45 Correct 253 ms 852 KB Output is correct
46 Correct 282 ms 624 KB Output is correct
47 Correct 247 ms 660 KB Output is correct
48 Correct 247 ms 744 KB Output is correct
49 Correct 243 ms 728 KB Output is correct
50 Correct 256 ms 676 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 301 ms 812 KB Output is correct
53 Correct 358 ms 716 KB Output is correct
54 Correct 489 ms 748 KB Output is correct
55 Correct 526 ms 1364 KB Output is correct
56 Correct 388 ms 756 KB Output is correct
57 Correct 503 ms 1236 KB Output is correct
58 Correct 489 ms 772 KB Output is correct
59 Correct 479 ms 832 KB Output is correct
60 Correct 0 ms 344 KB Output is correct
61 Correct 508 ms 1108 KB Output is correct
62 Correct 431 ms 1176 KB Output is correct
63 Correct 417 ms 1108 KB Output is correct
64 Correct 401 ms 1204 KB Output is correct
65 Correct 399 ms 604 KB Output is correct
66 Correct 370 ms 604 KB Output is correct
67 Correct 636 ms 856 KB Output is correct
68 Correct 3 ms 604 KB Output is correct
69 Execution timed out 1063 ms 1860 KB Time limit exceeded
70 Halted 0 ms 0 KB -