Submission #233733

# Submission time Handle Problem Language Result Execution time Memory
233733 2020-05-21T14:49:56 Z Haunted_Cpp Bootfall (IZhO17_bootfall) C++17
100 / 100
613 ms 4088 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 5e2 + 5;
const int S = N * N;

int cur [S];
int nxt [S];

int without [S];

bitset<S> ans;
bitset<S> Get;

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a (n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int whole_sum = accumulate (a.begin(), a.end(), 0);
  cur[0] = nxt[0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = a[i]; j < S; j++) {
      nxt[j] += cur[j - a[i]];
    }
    for (int j = 0; j < S; j++) {
      cur[j] = nxt[j];
    }
  }
  if ((whole_sum & 1) || (cur[whole_sum / 2] == 0) ) {
    cout << 0 << '\n';
    return 0;
  }
  ans.set();
  for (int i = 0; i < n; i++) {
    whole_sum -= a[i];
    for (int j = 0; j < S; j++) {
      without[j] = cur[j];
    }
    for (int j = a[i]; j < S; j++) {
      if (without[j]) without[j] -= without[j - a[i]];
    }
    Get.reset();
    for (int j = 0; j <= whole_sum; j++) {
      if (without[j]) {     
        int left = j;
        int right = whole_sum - j;
        Get[abs(left - right)] = 1;
      }
    }
    ans &= Get;
    whole_sum += a[i];
  } 
  cout << ans.count() << '\n';
  for (int i = 0; i < S; i++) if (ans[i]) cout << i << ' ';
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 10 ms 3328 KB Output is correct
2 Correct 11 ms 3328 KB Output is correct
3 Correct 6 ms 2304 KB Output is correct
4 Correct 10 ms 3456 KB Output is correct
5 Correct 15 ms 3328 KB Output is correct
6 Correct 13 ms 3328 KB Output is correct
7 Correct 10 ms 3328 KB Output is correct
8 Correct 19 ms 3328 KB Output is correct
9 Correct 14 ms 3456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 3328 KB Output is correct
2 Correct 11 ms 3328 KB Output is correct
3 Correct 6 ms 2304 KB Output is correct
4 Correct 10 ms 3456 KB Output is correct
5 Correct 15 ms 3328 KB Output is correct
6 Correct 13 ms 3328 KB Output is correct
7 Correct 10 ms 3328 KB Output is correct
8 Correct 19 ms 3328 KB Output is correct
9 Correct 14 ms 3456 KB Output is correct
10 Correct 28 ms 3456 KB Output is correct
11 Correct 27 ms 3456 KB Output is correct
12 Correct 28 ms 3328 KB Output is correct
13 Correct 26 ms 3328 KB Output is correct
14 Correct 27 ms 3328 KB Output is correct
15 Correct 26 ms 3328 KB Output is correct
16 Correct 29 ms 3328 KB Output is correct
17 Correct 19 ms 3328 KB Output is correct
18 Correct 24 ms 3328 KB Output is correct
19 Correct 25 ms 3328 KB Output is correct
20 Correct 28 ms 3440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 3328 KB Output is correct
2 Correct 11 ms 3328 KB Output is correct
3 Correct 6 ms 2304 KB Output is correct
4 Correct 10 ms 3456 KB Output is correct
5 Correct 15 ms 3328 KB Output is correct
6 Correct 13 ms 3328 KB Output is correct
7 Correct 10 ms 3328 KB Output is correct
8 Correct 19 ms 3328 KB Output is correct
9 Correct 14 ms 3456 KB Output is correct
10 Correct 28 ms 3456 KB Output is correct
11 Correct 27 ms 3456 KB Output is correct
12 Correct 28 ms 3328 KB Output is correct
13 Correct 26 ms 3328 KB Output is correct
14 Correct 27 ms 3328 KB Output is correct
15 Correct 26 ms 3328 KB Output is correct
16 Correct 29 ms 3328 KB Output is correct
17 Correct 19 ms 3328 KB Output is correct
18 Correct 24 ms 3328 KB Output is correct
19 Correct 25 ms 3328 KB Output is correct
20 Correct 28 ms 3440 KB Output is correct
21 Correct 51 ms 3412 KB Output is correct
22 Correct 59 ms 3448 KB Output is correct
23 Correct 43 ms 3328 KB Output is correct
24 Correct 76 ms 3452 KB Output is correct
25 Correct 75 ms 3448 KB Output is correct
26 Correct 83 ms 3448 KB Output is correct
27 Correct 79 ms 3448 KB Output is correct
28 Correct 78 ms 3432 KB Output is correct
29 Correct 79 ms 3440 KB Output is correct
30 Correct 77 ms 3452 KB Output is correct
31 Correct 80 ms 3448 KB Output is correct
32 Correct 78 ms 3448 KB Output is correct
33 Correct 79 ms 3320 KB Output is correct
34 Correct 81 ms 3328 KB Output is correct
35 Correct 79 ms 3456 KB Output is correct
36 Correct 80 ms 3448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 3328 KB Output is correct
2 Correct 11 ms 3328 KB Output is correct
3 Correct 6 ms 2304 KB Output is correct
4 Correct 10 ms 3456 KB Output is correct
5 Correct 15 ms 3328 KB Output is correct
6 Correct 13 ms 3328 KB Output is correct
7 Correct 10 ms 3328 KB Output is correct
8 Correct 19 ms 3328 KB Output is correct
9 Correct 14 ms 3456 KB Output is correct
10 Correct 28 ms 3456 KB Output is correct
11 Correct 27 ms 3456 KB Output is correct
12 Correct 28 ms 3328 KB Output is correct
13 Correct 26 ms 3328 KB Output is correct
14 Correct 27 ms 3328 KB Output is correct
15 Correct 26 ms 3328 KB Output is correct
16 Correct 29 ms 3328 KB Output is correct
17 Correct 19 ms 3328 KB Output is correct
18 Correct 24 ms 3328 KB Output is correct
19 Correct 25 ms 3328 KB Output is correct
20 Correct 28 ms 3440 KB Output is correct
21 Correct 51 ms 3412 KB Output is correct
22 Correct 59 ms 3448 KB Output is correct
23 Correct 43 ms 3328 KB Output is correct
24 Correct 76 ms 3452 KB Output is correct
25 Correct 75 ms 3448 KB Output is correct
26 Correct 83 ms 3448 KB Output is correct
27 Correct 79 ms 3448 KB Output is correct
28 Correct 78 ms 3432 KB Output is correct
29 Correct 79 ms 3440 KB Output is correct
30 Correct 77 ms 3452 KB Output is correct
31 Correct 80 ms 3448 KB Output is correct
32 Correct 78 ms 3448 KB Output is correct
33 Correct 79 ms 3320 KB Output is correct
34 Correct 81 ms 3328 KB Output is correct
35 Correct 79 ms 3456 KB Output is correct
36 Correct 80 ms 3448 KB Output is correct
37 Correct 160 ms 3448 KB Output is correct
38 Correct 164 ms 3444 KB Output is correct
39 Correct 199 ms 3448 KB Output is correct
40 Correct 217 ms 3448 KB Output is correct
41 Correct 213 ms 3320 KB Output is correct
42 Correct 207 ms 3448 KB Output is correct
43 Correct 205 ms 3576 KB Output is correct
44 Correct 223 ms 3576 KB Output is correct
45 Correct 220 ms 3576 KB Output is correct
46 Correct 206 ms 3320 KB Output is correct
47 Correct 199 ms 3448 KB Output is correct
48 Correct 213 ms 3560 KB Output is correct
49 Correct 211 ms 3448 KB Output is correct
50 Correct 202 ms 3532 KB Output is correct
51 Correct 89 ms 2304 KB Output is correct
52 Correct 236 ms 3576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 3328 KB Output is correct
2 Correct 11 ms 3328 KB Output is correct
3 Correct 6 ms 2304 KB Output is correct
4 Correct 10 ms 3456 KB Output is correct
5 Correct 15 ms 3328 KB Output is correct
6 Correct 13 ms 3328 KB Output is correct
7 Correct 10 ms 3328 KB Output is correct
8 Correct 19 ms 3328 KB Output is correct
9 Correct 14 ms 3456 KB Output is correct
10 Correct 28 ms 3456 KB Output is correct
11 Correct 27 ms 3456 KB Output is correct
12 Correct 28 ms 3328 KB Output is correct
13 Correct 26 ms 3328 KB Output is correct
14 Correct 27 ms 3328 KB Output is correct
15 Correct 26 ms 3328 KB Output is correct
16 Correct 29 ms 3328 KB Output is correct
17 Correct 19 ms 3328 KB Output is correct
18 Correct 24 ms 3328 KB Output is correct
19 Correct 25 ms 3328 KB Output is correct
20 Correct 28 ms 3440 KB Output is correct
21 Correct 51 ms 3412 KB Output is correct
22 Correct 59 ms 3448 KB Output is correct
23 Correct 43 ms 3328 KB Output is correct
24 Correct 76 ms 3452 KB Output is correct
25 Correct 75 ms 3448 KB Output is correct
26 Correct 83 ms 3448 KB Output is correct
27 Correct 79 ms 3448 KB Output is correct
28 Correct 78 ms 3432 KB Output is correct
29 Correct 79 ms 3440 KB Output is correct
30 Correct 77 ms 3452 KB Output is correct
31 Correct 80 ms 3448 KB Output is correct
32 Correct 78 ms 3448 KB Output is correct
33 Correct 79 ms 3320 KB Output is correct
34 Correct 81 ms 3328 KB Output is correct
35 Correct 79 ms 3456 KB Output is correct
36 Correct 80 ms 3448 KB Output is correct
37 Correct 160 ms 3448 KB Output is correct
38 Correct 164 ms 3444 KB Output is correct
39 Correct 199 ms 3448 KB Output is correct
40 Correct 217 ms 3448 KB Output is correct
41 Correct 213 ms 3320 KB Output is correct
42 Correct 207 ms 3448 KB Output is correct
43 Correct 205 ms 3576 KB Output is correct
44 Correct 223 ms 3576 KB Output is correct
45 Correct 220 ms 3576 KB Output is correct
46 Correct 206 ms 3320 KB Output is correct
47 Correct 199 ms 3448 KB Output is correct
48 Correct 213 ms 3560 KB Output is correct
49 Correct 211 ms 3448 KB Output is correct
50 Correct 202 ms 3532 KB Output is correct
51 Correct 89 ms 2304 KB Output is correct
52 Correct 236 ms 3576 KB Output is correct
53 Correct 242 ms 3552 KB Output is correct
54 Correct 304 ms 3608 KB Output is correct
55 Correct 341 ms 3704 KB Output is correct
56 Correct 270 ms 3576 KB Output is correct
57 Correct 339 ms 3704 KB Output is correct
58 Correct 298 ms 3576 KB Output is correct
59 Correct 309 ms 3560 KB Output is correct
60 Correct 117 ms 2304 KB Output is correct
61 Correct 320 ms 3576 KB Output is correct
62 Correct 301 ms 3704 KB Output is correct
63 Correct 305 ms 3704 KB Output is correct
64 Correct 309 ms 3704 KB Output is correct
65 Correct 256 ms 3448 KB Output is correct
66 Correct 250 ms 3448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 3328 KB Output is correct
2 Correct 11 ms 3328 KB Output is correct
3 Correct 6 ms 2304 KB Output is correct
4 Correct 10 ms 3456 KB Output is correct
5 Correct 15 ms 3328 KB Output is correct
6 Correct 13 ms 3328 KB Output is correct
7 Correct 10 ms 3328 KB Output is correct
8 Correct 19 ms 3328 KB Output is correct
9 Correct 14 ms 3456 KB Output is correct
10 Correct 28 ms 3456 KB Output is correct
11 Correct 27 ms 3456 KB Output is correct
12 Correct 28 ms 3328 KB Output is correct
13 Correct 26 ms 3328 KB Output is correct
14 Correct 27 ms 3328 KB Output is correct
15 Correct 26 ms 3328 KB Output is correct
16 Correct 29 ms 3328 KB Output is correct
17 Correct 19 ms 3328 KB Output is correct
18 Correct 24 ms 3328 KB Output is correct
19 Correct 25 ms 3328 KB Output is correct
20 Correct 28 ms 3440 KB Output is correct
21 Correct 51 ms 3412 KB Output is correct
22 Correct 59 ms 3448 KB Output is correct
23 Correct 43 ms 3328 KB Output is correct
24 Correct 76 ms 3452 KB Output is correct
25 Correct 75 ms 3448 KB Output is correct
26 Correct 83 ms 3448 KB Output is correct
27 Correct 79 ms 3448 KB Output is correct
28 Correct 78 ms 3432 KB Output is correct
29 Correct 79 ms 3440 KB Output is correct
30 Correct 77 ms 3452 KB Output is correct
31 Correct 80 ms 3448 KB Output is correct
32 Correct 78 ms 3448 KB Output is correct
33 Correct 79 ms 3320 KB Output is correct
34 Correct 81 ms 3328 KB Output is correct
35 Correct 79 ms 3456 KB Output is correct
36 Correct 80 ms 3448 KB Output is correct
37 Correct 160 ms 3448 KB Output is correct
38 Correct 164 ms 3444 KB Output is correct
39 Correct 199 ms 3448 KB Output is correct
40 Correct 217 ms 3448 KB Output is correct
41 Correct 213 ms 3320 KB Output is correct
42 Correct 207 ms 3448 KB Output is correct
43 Correct 205 ms 3576 KB Output is correct
44 Correct 223 ms 3576 KB Output is correct
45 Correct 220 ms 3576 KB Output is correct
46 Correct 206 ms 3320 KB Output is correct
47 Correct 199 ms 3448 KB Output is correct
48 Correct 213 ms 3560 KB Output is correct
49 Correct 211 ms 3448 KB Output is correct
50 Correct 202 ms 3532 KB Output is correct
51 Correct 89 ms 2304 KB Output is correct
52 Correct 236 ms 3576 KB Output is correct
53 Correct 242 ms 3552 KB Output is correct
54 Correct 304 ms 3608 KB Output is correct
55 Correct 341 ms 3704 KB Output is correct
56 Correct 270 ms 3576 KB Output is correct
57 Correct 339 ms 3704 KB Output is correct
58 Correct 298 ms 3576 KB Output is correct
59 Correct 309 ms 3560 KB Output is correct
60 Correct 117 ms 2304 KB Output is correct
61 Correct 320 ms 3576 KB Output is correct
62 Correct 301 ms 3704 KB Output is correct
63 Correct 305 ms 3704 KB Output is correct
64 Correct 309 ms 3704 KB Output is correct
65 Correct 256 ms 3448 KB Output is correct
66 Correct 250 ms 3448 KB Output is correct
67 Correct 357 ms 3576 KB Output is correct
68 Correct 156 ms 2304 KB Output is correct
69 Correct 595 ms 4088 KB Output is correct
70 Correct 500 ms 4088 KB Output is correct
71 Correct 505 ms 3832 KB Output is correct
72 Correct 489 ms 3448 KB Output is correct
73 Correct 487 ms 3448 KB Output is correct
74 Correct 598 ms 4088 KB Output is correct
75 Correct 556 ms 3960 KB Output is correct
76 Correct 609 ms 4084 KB Output is correct
77 Correct 613 ms 4088 KB Output is correct