Submission #95519

# Submission time Handle Problem Language Result Execution time Memory
95519 2019-02-01T17:58:57 Z choikiwon Bootfall (IZhO17_bootfall) C++17
100 / 100
486 ms 2168 KB
#include<bits/stdc++.h>
using namespace std;

const int MN = 502;
const int SQ = 22;

int N;
int A[MN];
bitset<MN * MN> dp, tmp;
int cnt[MN * MN];

int main() {
    scanf("%d", &N);

    int sum = 0;
    for(int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
        sum += A[i];
    }
    if(sum % 2) {
        printf("0");
        return 0;
    }

    dp[0] = 1;
    for(int i = 0; i < N; i++) {
        dp |= (dp << A[i]);
    }
    if(!dp[sum / 2]) {
        printf("0");
        return 0;
    }

    for(int l = 0; l < N; l += SQ) {
        int r = min(N, l + SQ) - 1;

        dp.reset();
        dp[0] = 1;
        for(int i = 0; i < N; i++) {
            if(l <= i && i <= r) continue;
            dp |= (dp << A[i]);
        }

        for(int i = l; i <= r; i++) {
            tmp = dp;

            for(int j = l; j <= r; j++) {
                if(j == i) continue;
                tmp |= (tmp << A[j]);
            }

            for(int j = 0; j < MN * MN; j++) {
                if(tmp[j] && 2 * j + A[i] - sum >= 0) {
                    cnt[ 2 * j + A[i] - sum ]++;
                }
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < MN * MN; i++) {
        if(cnt[i] == N) ans++;
    }
    printf("%d\n", ans);
    for(int i = 0; i < MN * MN; i++) {
        if(cnt[i] == N) printf("%d ", i);
    }
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
bootfall.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &A[i]);
         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 4 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 8 ms 504 KB Output is correct
6 Correct 5 ms 380 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 7 ms 504 KB Output is correct
9 Correct 6 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 4 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 8 ms 504 KB Output is correct
6 Correct 5 ms 380 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 7 ms 504 KB Output is correct
9 Correct 6 ms 504 KB Output is correct
10 Correct 17 ms 376 KB Output is correct
11 Correct 17 ms 376 KB Output is correct
12 Correct 17 ms 492 KB Output is correct
13 Correct 18 ms 632 KB Output is correct
14 Correct 16 ms 504 KB Output is correct
15 Correct 17 ms 476 KB Output is correct
16 Correct 17 ms 380 KB Output is correct
17 Correct 11 ms 248 KB Output is correct
18 Correct 15 ms 504 KB Output is correct
19 Correct 16 ms 504 KB Output is correct
20 Correct 19 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 4 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 8 ms 504 KB Output is correct
6 Correct 5 ms 380 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 7 ms 504 KB Output is correct
9 Correct 6 ms 504 KB Output is correct
10 Correct 17 ms 376 KB Output is correct
11 Correct 17 ms 376 KB Output is correct
12 Correct 17 ms 492 KB Output is correct
13 Correct 18 ms 632 KB Output is correct
14 Correct 16 ms 504 KB Output is correct
15 Correct 17 ms 476 KB Output is correct
16 Correct 17 ms 380 KB Output is correct
17 Correct 11 ms 248 KB Output is correct
18 Correct 15 ms 504 KB Output is correct
19 Correct 16 ms 504 KB Output is correct
20 Correct 19 ms 504 KB Output is correct
21 Correct 38 ms 504 KB Output is correct
22 Correct 46 ms 500 KB Output is correct
23 Correct 30 ms 504 KB Output is correct
24 Correct 58 ms 504 KB Output is correct
25 Correct 56 ms 476 KB Output is correct
26 Correct 60 ms 504 KB Output is correct
27 Correct 61 ms 604 KB Output is correct
28 Correct 63 ms 504 KB Output is correct
29 Correct 63 ms 504 KB Output is correct
30 Correct 60 ms 504 KB Output is correct
31 Correct 59 ms 504 KB Output is correct
32 Correct 58 ms 504 KB Output is correct
33 Correct 60 ms 504 KB Output is correct
34 Correct 60 ms 504 KB Output is correct
35 Correct 60 ms 632 KB Output is correct
36 Correct 60 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 4 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 8 ms 504 KB Output is correct
6 Correct 5 ms 380 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 7 ms 504 KB Output is correct
9 Correct 6 ms 504 KB Output is correct
10 Correct 17 ms 376 KB Output is correct
11 Correct 17 ms 376 KB Output is correct
12 Correct 17 ms 492 KB Output is correct
13 Correct 18 ms 632 KB Output is correct
14 Correct 16 ms 504 KB Output is correct
15 Correct 17 ms 476 KB Output is correct
16 Correct 17 ms 380 KB Output is correct
17 Correct 11 ms 248 KB Output is correct
18 Correct 15 ms 504 KB Output is correct
19 Correct 16 ms 504 KB Output is correct
20 Correct 19 ms 504 KB Output is correct
21 Correct 38 ms 504 KB Output is correct
22 Correct 46 ms 500 KB Output is correct
23 Correct 30 ms 504 KB Output is correct
24 Correct 58 ms 504 KB Output is correct
25 Correct 56 ms 476 KB Output is correct
26 Correct 60 ms 504 KB Output is correct
27 Correct 61 ms 604 KB Output is correct
28 Correct 63 ms 504 KB Output is correct
29 Correct 63 ms 504 KB Output is correct
30 Correct 60 ms 504 KB Output is correct
31 Correct 59 ms 504 KB Output is correct
32 Correct 58 ms 504 KB Output is correct
33 Correct 60 ms 504 KB Output is correct
34 Correct 60 ms 504 KB Output is correct
35 Correct 60 ms 632 KB Output is correct
36 Correct 60 ms 504 KB Output is correct
37 Correct 133 ms 600 KB Output is correct
38 Correct 133 ms 568 KB Output is correct
39 Correct 178 ms 724 KB Output is correct
40 Correct 191 ms 760 KB Output is correct
41 Correct 188 ms 760 KB Output is correct
42 Correct 177 ms 640 KB Output is correct
43 Correct 178 ms 860 KB Output is correct
44 Correct 173 ms 848 KB Output is correct
45 Correct 173 ms 840 KB Output is correct
46 Correct 188 ms 760 KB Output is correct
47 Correct 181 ms 604 KB Output is correct
48 Correct 171 ms 732 KB Output is correct
49 Correct 179 ms 860 KB Output is correct
50 Correct 183 ms 760 KB Output is correct
51 Correct 2 ms 256 KB Output is correct
52 Correct 190 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 4 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 8 ms 504 KB Output is correct
6 Correct 5 ms 380 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 7 ms 504 KB Output is correct
9 Correct 6 ms 504 KB Output is correct
10 Correct 17 ms 376 KB Output is correct
11 Correct 17 ms 376 KB Output is correct
12 Correct 17 ms 492 KB Output is correct
13 Correct 18 ms 632 KB Output is correct
14 Correct 16 ms 504 KB Output is correct
15 Correct 17 ms 476 KB Output is correct
16 Correct 17 ms 380 KB Output is correct
17 Correct 11 ms 248 KB Output is correct
18 Correct 15 ms 504 KB Output is correct
19 Correct 16 ms 504 KB Output is correct
20 Correct 19 ms 504 KB Output is correct
21 Correct 38 ms 504 KB Output is correct
22 Correct 46 ms 500 KB Output is correct
23 Correct 30 ms 504 KB Output is correct
24 Correct 58 ms 504 KB Output is correct
25 Correct 56 ms 476 KB Output is correct
26 Correct 60 ms 504 KB Output is correct
27 Correct 61 ms 604 KB Output is correct
28 Correct 63 ms 504 KB Output is correct
29 Correct 63 ms 504 KB Output is correct
30 Correct 60 ms 504 KB Output is correct
31 Correct 59 ms 504 KB Output is correct
32 Correct 58 ms 504 KB Output is correct
33 Correct 60 ms 504 KB Output is correct
34 Correct 60 ms 504 KB Output is correct
35 Correct 60 ms 632 KB Output is correct
36 Correct 60 ms 504 KB Output is correct
37 Correct 133 ms 600 KB Output is correct
38 Correct 133 ms 568 KB Output is correct
39 Correct 178 ms 724 KB Output is correct
40 Correct 191 ms 760 KB Output is correct
41 Correct 188 ms 760 KB Output is correct
42 Correct 177 ms 640 KB Output is correct
43 Correct 178 ms 860 KB Output is correct
44 Correct 173 ms 848 KB Output is correct
45 Correct 173 ms 840 KB Output is correct
46 Correct 188 ms 760 KB Output is correct
47 Correct 181 ms 604 KB Output is correct
48 Correct 171 ms 732 KB Output is correct
49 Correct 179 ms 860 KB Output is correct
50 Correct 183 ms 760 KB Output is correct
51 Correct 2 ms 256 KB Output is correct
52 Correct 190 ms 888 KB Output is correct
53 Correct 232 ms 828 KB Output is correct
54 Correct 269 ms 888 KB Output is correct
55 Correct 276 ms 1184 KB Output is correct
56 Correct 231 ms 888 KB Output is correct
57 Correct 283 ms 1272 KB Output is correct
58 Correct 269 ms 888 KB Output is correct
59 Correct 279 ms 1016 KB Output is correct
60 Correct 2 ms 380 KB Output is correct
61 Correct 275 ms 988 KB Output is correct
62 Correct 255 ms 1116 KB Output is correct
63 Correct 251 ms 1144 KB Output is correct
64 Correct 245 ms 1272 KB Output is correct
65 Correct 247 ms 760 KB Output is correct
66 Correct 224 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 4 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 8 ms 504 KB Output is correct
6 Correct 5 ms 380 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 7 ms 504 KB Output is correct
9 Correct 6 ms 504 KB Output is correct
10 Correct 17 ms 376 KB Output is correct
11 Correct 17 ms 376 KB Output is correct
12 Correct 17 ms 492 KB Output is correct
13 Correct 18 ms 632 KB Output is correct
14 Correct 16 ms 504 KB Output is correct
15 Correct 17 ms 476 KB Output is correct
16 Correct 17 ms 380 KB Output is correct
17 Correct 11 ms 248 KB Output is correct
18 Correct 15 ms 504 KB Output is correct
19 Correct 16 ms 504 KB Output is correct
20 Correct 19 ms 504 KB Output is correct
21 Correct 38 ms 504 KB Output is correct
22 Correct 46 ms 500 KB Output is correct
23 Correct 30 ms 504 KB Output is correct
24 Correct 58 ms 504 KB Output is correct
25 Correct 56 ms 476 KB Output is correct
26 Correct 60 ms 504 KB Output is correct
27 Correct 61 ms 604 KB Output is correct
28 Correct 63 ms 504 KB Output is correct
29 Correct 63 ms 504 KB Output is correct
30 Correct 60 ms 504 KB Output is correct
31 Correct 59 ms 504 KB Output is correct
32 Correct 58 ms 504 KB Output is correct
33 Correct 60 ms 504 KB Output is correct
34 Correct 60 ms 504 KB Output is correct
35 Correct 60 ms 632 KB Output is correct
36 Correct 60 ms 504 KB Output is correct
37 Correct 133 ms 600 KB Output is correct
38 Correct 133 ms 568 KB Output is correct
39 Correct 178 ms 724 KB Output is correct
40 Correct 191 ms 760 KB Output is correct
41 Correct 188 ms 760 KB Output is correct
42 Correct 177 ms 640 KB Output is correct
43 Correct 178 ms 860 KB Output is correct
44 Correct 173 ms 848 KB Output is correct
45 Correct 173 ms 840 KB Output is correct
46 Correct 188 ms 760 KB Output is correct
47 Correct 181 ms 604 KB Output is correct
48 Correct 171 ms 732 KB Output is correct
49 Correct 179 ms 860 KB Output is correct
50 Correct 183 ms 760 KB Output is correct
51 Correct 2 ms 256 KB Output is correct
52 Correct 190 ms 888 KB Output is correct
53 Correct 232 ms 828 KB Output is correct
54 Correct 269 ms 888 KB Output is correct
55 Correct 276 ms 1184 KB Output is correct
56 Correct 231 ms 888 KB Output is correct
57 Correct 283 ms 1272 KB Output is correct
58 Correct 269 ms 888 KB Output is correct
59 Correct 279 ms 1016 KB Output is correct
60 Correct 2 ms 380 KB Output is correct
61 Correct 275 ms 988 KB Output is correct
62 Correct 255 ms 1116 KB Output is correct
63 Correct 251 ms 1144 KB Output is correct
64 Correct 245 ms 1272 KB Output is correct
65 Correct 247 ms 760 KB Output is correct
66 Correct 224 ms 760 KB Output is correct
67 Correct 335 ms 964 KB Output is correct
68 Correct 7 ms 376 KB Output is correct
69 Correct 458 ms 2040 KB Output is correct
70 Correct 456 ms 1272 KB Output is correct
71 Correct 438 ms 1400 KB Output is correct
72 Correct 442 ms 1076 KB Output is correct
73 Correct 470 ms 1012 KB Output is correct
74 Correct 464 ms 2168 KB Output is correct
75 Correct 464 ms 1784 KB Output is correct
76 Correct 472 ms 2092 KB Output is correct
77 Correct 486 ms 2168 KB Output is correct