Submission #315314

# Submission time Handle Problem Language Result Execution time Memory
315314 2020-10-22T10:22:32 Z dolphingarlic Bootfall (IZhO17_bootfall) C++14
65 / 100
1000 ms 1400 KB
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
#pragma GCC target("sse4,avx2,fma,avx")
using namespace std;

int main() {
    int n, a[500], tot = 0;
    scanf("%d", &n);
    bitset<125001> base;
    base[0] = 1;
    for (int i = 0; i < n; i++) {
        scanf("%d", a + i);
        tot += a[i];
        base |= base << a[i];
    }
    if ((tot & 1) || !base[tot >> 1]) return printf("0"), 0;

    bitset<125001> ans;
    for (int i = 1; i <= tot; i++) ans[i] = 1;

    for (int i = 0; i < n; i++) {
        bitset<125001> possible, good;
        possible[0] = 1;
        for (int j = 0; j < n; j++) if (j != i) possible |= possible << a[j];
        for (int j = tot - a[i] & 1; j <= tot - a[i]; j += 2) good[j] = possible[tot - a[i] - j >> 1];
        ans &= good;
    }

    printf("%d\n", ans.count());
    for (int i = 0; i <= tot; i++) if (ans[i]) printf("%d ", i);
    return 0;
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:26:26: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   26 |         for (int j = tot - a[i] & 1; j <= tot - a[i]; j += 2) good[j] = possible[tot - a[i] - j >> 1];
      |                      ~~~~^~~~~~
bootfall.cpp:26:93: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
   26 |         for (int j = tot - a[i] & 1; j <= tot - a[i]; j += 2) good[j] = possible[tot - a[i] - j >> 1];
      |                                                                                  ~~~~~~~~~~~^~~
bootfall.cpp:30:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::size_t' {aka 'long unsigned int'} [-Wformat=]
   30 |     printf("%d\n", ans.count());
      |             ~^     ~~~~~~~~~~~
      |              |              |
      |              int            std::size_t {aka long unsigned int}
      |             %ld
bootfall.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
bootfall.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |         scanf("%d", a + i);
      |         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 17 ms 384 KB Output is correct
22 Correct 22 ms 384 KB Output is correct
23 Correct 11 ms 384 KB Output is correct
24 Correct 36 ms 384 KB Output is correct
25 Correct 38 ms 384 KB Output is correct
26 Correct 41 ms 460 KB Output is correct
27 Correct 40 ms 504 KB Output is correct
28 Correct 40 ms 384 KB Output is correct
29 Correct 40 ms 384 KB Output is correct
30 Correct 40 ms 384 KB Output is correct
31 Correct 40 ms 384 KB Output is correct
32 Correct 40 ms 384 KB Output is correct
33 Correct 40 ms 384 KB Output is correct
34 Correct 40 ms 384 KB Output is correct
35 Correct 40 ms 384 KB Output is correct
36 Correct 41 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 17 ms 384 KB Output is correct
22 Correct 22 ms 384 KB Output is correct
23 Correct 11 ms 384 KB Output is correct
24 Correct 36 ms 384 KB Output is correct
25 Correct 38 ms 384 KB Output is correct
26 Correct 41 ms 460 KB Output is correct
27 Correct 40 ms 504 KB Output is correct
28 Correct 40 ms 384 KB Output is correct
29 Correct 40 ms 384 KB Output is correct
30 Correct 40 ms 384 KB Output is correct
31 Correct 40 ms 384 KB Output is correct
32 Correct 40 ms 384 KB Output is correct
33 Correct 40 ms 384 KB Output is correct
34 Correct 40 ms 384 KB Output is correct
35 Correct 40 ms 384 KB Output is correct
36 Correct 41 ms 384 KB Output is correct
37 Correct 160 ms 452 KB Output is correct
38 Correct 159 ms 504 KB Output is correct
39 Correct 267 ms 384 KB Output is correct
40 Correct 293 ms 448 KB Output is correct
41 Correct 301 ms 504 KB Output is correct
42 Correct 250 ms 504 KB Output is correct
43 Correct 248 ms 632 KB Output is correct
44 Correct 261 ms 504 KB Output is correct
45 Correct 263 ms 632 KB Output is correct
46 Correct 295 ms 504 KB Output is correct
47 Correct 257 ms 452 KB Output is correct
48 Correct 263 ms 504 KB Output is correct
49 Correct 262 ms 384 KB Output is correct
50 Correct 259 ms 504 KB Output is correct
51 Correct 2 ms 384 KB Output is correct
52 Correct 300 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 17 ms 384 KB Output is correct
22 Correct 22 ms 384 KB Output is correct
23 Correct 11 ms 384 KB Output is correct
24 Correct 36 ms 384 KB Output is correct
25 Correct 38 ms 384 KB Output is correct
26 Correct 41 ms 460 KB Output is correct
27 Correct 40 ms 504 KB Output is correct
28 Correct 40 ms 384 KB Output is correct
29 Correct 40 ms 384 KB Output is correct
30 Correct 40 ms 384 KB Output is correct
31 Correct 40 ms 384 KB Output is correct
32 Correct 40 ms 384 KB Output is correct
33 Correct 40 ms 384 KB Output is correct
34 Correct 40 ms 384 KB Output is correct
35 Correct 40 ms 384 KB Output is correct
36 Correct 41 ms 384 KB Output is correct
37 Correct 160 ms 452 KB Output is correct
38 Correct 159 ms 504 KB Output is correct
39 Correct 267 ms 384 KB Output is correct
40 Correct 293 ms 448 KB Output is correct
41 Correct 301 ms 504 KB Output is correct
42 Correct 250 ms 504 KB Output is correct
43 Correct 248 ms 632 KB Output is correct
44 Correct 261 ms 504 KB Output is correct
45 Correct 263 ms 632 KB Output is correct
46 Correct 295 ms 504 KB Output is correct
47 Correct 257 ms 452 KB Output is correct
48 Correct 263 ms 504 KB Output is correct
49 Correct 262 ms 384 KB Output is correct
50 Correct 259 ms 504 KB Output is correct
51 Correct 2 ms 384 KB Output is correct
52 Correct 300 ms 504 KB Output is correct
53 Correct 368 ms 504 KB Output is correct
54 Correct 501 ms 504 KB Output is correct
55 Correct 511 ms 760 KB Output is correct
56 Correct 380 ms 632 KB Output is correct
57 Correct 518 ms 760 KB Output is correct
58 Correct 499 ms 632 KB Output is correct
59 Correct 504 ms 632 KB Output is correct
60 Correct 2 ms 384 KB Output is correct
61 Correct 506 ms 584 KB Output is correct
62 Correct 429 ms 760 KB Output is correct
63 Correct 433 ms 632 KB Output is correct
64 Correct 414 ms 888 KB Output is correct
65 Correct 400 ms 504 KB Output is correct
66 Correct 395 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 17 ms 384 KB Output is correct
22 Correct 22 ms 384 KB Output is correct
23 Correct 11 ms 384 KB Output is correct
24 Correct 36 ms 384 KB Output is correct
25 Correct 38 ms 384 KB Output is correct
26 Correct 41 ms 460 KB Output is correct
27 Correct 40 ms 504 KB Output is correct
28 Correct 40 ms 384 KB Output is correct
29 Correct 40 ms 384 KB Output is correct
30 Correct 40 ms 384 KB Output is correct
31 Correct 40 ms 384 KB Output is correct
32 Correct 40 ms 384 KB Output is correct
33 Correct 40 ms 384 KB Output is correct
34 Correct 40 ms 384 KB Output is correct
35 Correct 40 ms 384 KB Output is correct
36 Correct 41 ms 384 KB Output is correct
37 Correct 160 ms 452 KB Output is correct
38 Correct 159 ms 504 KB Output is correct
39 Correct 267 ms 384 KB Output is correct
40 Correct 293 ms 448 KB Output is correct
41 Correct 301 ms 504 KB Output is correct
42 Correct 250 ms 504 KB Output is correct
43 Correct 248 ms 632 KB Output is correct
44 Correct 261 ms 504 KB Output is correct
45 Correct 263 ms 632 KB Output is correct
46 Correct 295 ms 504 KB Output is correct
47 Correct 257 ms 452 KB Output is correct
48 Correct 263 ms 504 KB Output is correct
49 Correct 262 ms 384 KB Output is correct
50 Correct 259 ms 504 KB Output is correct
51 Correct 2 ms 384 KB Output is correct
52 Correct 300 ms 504 KB Output is correct
53 Correct 368 ms 504 KB Output is correct
54 Correct 501 ms 504 KB Output is correct
55 Correct 511 ms 760 KB Output is correct
56 Correct 380 ms 632 KB Output is correct
57 Correct 518 ms 760 KB Output is correct
58 Correct 499 ms 632 KB Output is correct
59 Correct 504 ms 632 KB Output is correct
60 Correct 2 ms 384 KB Output is correct
61 Correct 506 ms 584 KB Output is correct
62 Correct 429 ms 760 KB Output is correct
63 Correct 433 ms 632 KB Output is correct
64 Correct 414 ms 888 KB Output is correct
65 Correct 400 ms 504 KB Output is correct
66 Correct 395 ms 504 KB Output is correct
67 Correct 653 ms 632 KB Output is correct
68 Correct 3 ms 384 KB Output is correct
69 Execution timed out 1085 ms 1400 KB Time limit exceeded
70 Halted 0 ms 0 KB -