Submission #233716

# Submission time Handle Problem Language Result Execution time Memory
233716 2020-05-21T14:09:54 Z Haunted_Cpp Bootfall (IZhO17_bootfall) C++17
44 / 100
1000 ms 760 KB
#include <bits/stdc++.h>
using namespace std;

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

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

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a (n + 1);
  for (int i = 0; i < n; i++) cin >> a[i];
  ans.set();
  int whole_sum = accumulate (a.begin(), a.end(), 0);
  for (int i = 0; i <= n; i++) {
    int was = a[i];    
    a[i] = 0;
    whole_sum -= was;
    
    is_possible.reset();
    is_possible[0] = 1;
    for (int j = 0; j < n; j++) {
      is_possible |= (is_possible << a[j]);
    }
    
    Get.reset();
    
    bool is_there_valid = false;
    for (int j = 0; j <= whole_sum; j++) {
      if (is_possible[j]) {
        int left = j;
        int right = whole_sum - j;
     //   cout << left << ' ' << right << '\n';
        if (i == n && left == right) is_there_valid = true;
        Get[abs(left - right)] = 1;
      }
    }
    
    if (i == n) {
      if (!is_there_valid) {
        cout << 0 << '\n';
        return 0;
      } else break;
    }
    
    ans &= Get;
    whole_sum += was;
    a[i] = was;
  }
  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 5 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 6 ms 512 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 6 ms 512 KB Output is correct
9 Correct 6 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 6 ms 512 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 6 ms 512 KB Output is correct
9 Correct 6 ms 512 KB Output is correct
10 Correct 14 ms 512 KB Output is correct
11 Correct 13 ms 512 KB Output is correct
12 Correct 13 ms 512 KB Output is correct
13 Correct 11 ms 512 KB Output is correct
14 Correct 12 ms 640 KB Output is correct
15 Correct 12 ms 512 KB Output is correct
16 Correct 13 ms 512 KB Output is correct
17 Correct 8 ms 512 KB Output is correct
18 Correct 10 ms 512 KB Output is correct
19 Correct 11 ms 512 KB Output is correct
20 Correct 13 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 6 ms 512 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 6 ms 512 KB Output is correct
9 Correct 6 ms 512 KB Output is correct
10 Correct 14 ms 512 KB Output is correct
11 Correct 13 ms 512 KB Output is correct
12 Correct 13 ms 512 KB Output is correct
13 Correct 11 ms 512 KB Output is correct
14 Correct 12 ms 640 KB Output is correct
15 Correct 12 ms 512 KB Output is correct
16 Correct 13 ms 512 KB Output is correct
17 Correct 8 ms 512 KB Output is correct
18 Correct 10 ms 512 KB Output is correct
19 Correct 11 ms 512 KB Output is correct
20 Correct 13 ms 512 KB Output is correct
21 Correct 46 ms 560 KB Output is correct
22 Correct 55 ms 512 KB Output is correct
23 Correct 28 ms 512 KB Output is correct
24 Correct 96 ms 660 KB Output is correct
25 Correct 91 ms 512 KB Output is correct
26 Correct 100 ms 512 KB Output is correct
27 Correct 95 ms 532 KB Output is correct
28 Correct 97 ms 512 KB Output is correct
29 Correct 99 ms 512 KB Output is correct
30 Correct 102 ms 512 KB Output is correct
31 Correct 98 ms 512 KB Output is correct
32 Correct 97 ms 512 KB Output is correct
33 Correct 94 ms 512 KB Output is correct
34 Correct 112 ms 632 KB Output is correct
35 Correct 100 ms 512 KB Output is correct
36 Correct 102 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 6 ms 512 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 6 ms 512 KB Output is correct
9 Correct 6 ms 512 KB Output is correct
10 Correct 14 ms 512 KB Output is correct
11 Correct 13 ms 512 KB Output is correct
12 Correct 13 ms 512 KB Output is correct
13 Correct 11 ms 512 KB Output is correct
14 Correct 12 ms 640 KB Output is correct
15 Correct 12 ms 512 KB Output is correct
16 Correct 13 ms 512 KB Output is correct
17 Correct 8 ms 512 KB Output is correct
18 Correct 10 ms 512 KB Output is correct
19 Correct 11 ms 512 KB Output is correct
20 Correct 13 ms 512 KB Output is correct
21 Correct 46 ms 560 KB Output is correct
22 Correct 55 ms 512 KB Output is correct
23 Correct 28 ms 512 KB Output is correct
24 Correct 96 ms 660 KB Output is correct
25 Correct 91 ms 512 KB Output is correct
26 Correct 100 ms 512 KB Output is correct
27 Correct 95 ms 532 KB Output is correct
28 Correct 97 ms 512 KB Output is correct
29 Correct 99 ms 512 KB Output is correct
30 Correct 102 ms 512 KB Output is correct
31 Correct 98 ms 512 KB Output is correct
32 Correct 97 ms 512 KB Output is correct
33 Correct 94 ms 512 KB Output is correct
34 Correct 112 ms 632 KB Output is correct
35 Correct 100 ms 512 KB Output is correct
36 Correct 102 ms 512 KB Output is correct
37 Correct 382 ms 632 KB Output is correct
38 Correct 408 ms 564 KB Output is correct
39 Correct 584 ms 608 KB Output is correct
40 Correct 683 ms 632 KB Output is correct
41 Correct 697 ms 632 KB Output is correct
42 Correct 575 ms 512 KB Output is correct
43 Correct 581 ms 760 KB Output is correct
44 Correct 583 ms 760 KB Output is correct
45 Correct 588 ms 760 KB Output is correct
46 Correct 656 ms 632 KB Output is correct
47 Correct 600 ms 512 KB Output is correct
48 Correct 592 ms 524 KB Output is correct
49 Correct 598 ms 512 KB Output is correct
50 Correct 595 ms 632 KB Output is correct
51 Correct 589 ms 632 KB Output is correct
52 Correct 713 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 6 ms 512 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 6 ms 512 KB Output is correct
9 Correct 6 ms 512 KB Output is correct
10 Correct 14 ms 512 KB Output is correct
11 Correct 13 ms 512 KB Output is correct
12 Correct 13 ms 512 KB Output is correct
13 Correct 11 ms 512 KB Output is correct
14 Correct 12 ms 640 KB Output is correct
15 Correct 12 ms 512 KB Output is correct
16 Correct 13 ms 512 KB Output is correct
17 Correct 8 ms 512 KB Output is correct
18 Correct 10 ms 512 KB Output is correct
19 Correct 11 ms 512 KB Output is correct
20 Correct 13 ms 512 KB Output is correct
21 Correct 46 ms 560 KB Output is correct
22 Correct 55 ms 512 KB Output is correct
23 Correct 28 ms 512 KB Output is correct
24 Correct 96 ms 660 KB Output is correct
25 Correct 91 ms 512 KB Output is correct
26 Correct 100 ms 512 KB Output is correct
27 Correct 95 ms 532 KB Output is correct
28 Correct 97 ms 512 KB Output is correct
29 Correct 99 ms 512 KB Output is correct
30 Correct 102 ms 512 KB Output is correct
31 Correct 98 ms 512 KB Output is correct
32 Correct 97 ms 512 KB Output is correct
33 Correct 94 ms 512 KB Output is correct
34 Correct 112 ms 632 KB Output is correct
35 Correct 100 ms 512 KB Output is correct
36 Correct 102 ms 512 KB Output is correct
37 Correct 382 ms 632 KB Output is correct
38 Correct 408 ms 564 KB Output is correct
39 Correct 584 ms 608 KB Output is correct
40 Correct 683 ms 632 KB Output is correct
41 Correct 697 ms 632 KB Output is correct
42 Correct 575 ms 512 KB Output is correct
43 Correct 581 ms 760 KB Output is correct
44 Correct 583 ms 760 KB Output is correct
45 Correct 588 ms 760 KB Output is correct
46 Correct 656 ms 632 KB Output is correct
47 Correct 600 ms 512 KB Output is correct
48 Correct 592 ms 524 KB Output is correct
49 Correct 598 ms 512 KB Output is correct
50 Correct 595 ms 632 KB Output is correct
51 Correct 589 ms 632 KB Output is correct
52 Correct 713 ms 632 KB Output is correct
53 Correct 836 ms 664 KB Output is correct
54 Execution timed out 1091 ms 512 KB Time limit exceeded
55 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 6 ms 512 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 6 ms 512 KB Output is correct
9 Correct 6 ms 512 KB Output is correct
10 Correct 14 ms 512 KB Output is correct
11 Correct 13 ms 512 KB Output is correct
12 Correct 13 ms 512 KB Output is correct
13 Correct 11 ms 512 KB Output is correct
14 Correct 12 ms 640 KB Output is correct
15 Correct 12 ms 512 KB Output is correct
16 Correct 13 ms 512 KB Output is correct
17 Correct 8 ms 512 KB Output is correct
18 Correct 10 ms 512 KB Output is correct
19 Correct 11 ms 512 KB Output is correct
20 Correct 13 ms 512 KB Output is correct
21 Correct 46 ms 560 KB Output is correct
22 Correct 55 ms 512 KB Output is correct
23 Correct 28 ms 512 KB Output is correct
24 Correct 96 ms 660 KB Output is correct
25 Correct 91 ms 512 KB Output is correct
26 Correct 100 ms 512 KB Output is correct
27 Correct 95 ms 532 KB Output is correct
28 Correct 97 ms 512 KB Output is correct
29 Correct 99 ms 512 KB Output is correct
30 Correct 102 ms 512 KB Output is correct
31 Correct 98 ms 512 KB Output is correct
32 Correct 97 ms 512 KB Output is correct
33 Correct 94 ms 512 KB Output is correct
34 Correct 112 ms 632 KB Output is correct
35 Correct 100 ms 512 KB Output is correct
36 Correct 102 ms 512 KB Output is correct
37 Correct 382 ms 632 KB Output is correct
38 Correct 408 ms 564 KB Output is correct
39 Correct 584 ms 608 KB Output is correct
40 Correct 683 ms 632 KB Output is correct
41 Correct 697 ms 632 KB Output is correct
42 Correct 575 ms 512 KB Output is correct
43 Correct 581 ms 760 KB Output is correct
44 Correct 583 ms 760 KB Output is correct
45 Correct 588 ms 760 KB Output is correct
46 Correct 656 ms 632 KB Output is correct
47 Correct 600 ms 512 KB Output is correct
48 Correct 592 ms 524 KB Output is correct
49 Correct 598 ms 512 KB Output is correct
50 Correct 595 ms 632 KB Output is correct
51 Correct 589 ms 632 KB Output is correct
52 Correct 713 ms 632 KB Output is correct
53 Correct 836 ms 664 KB Output is correct
54 Execution timed out 1091 ms 512 KB Time limit exceeded
55 Halted 0 ms 0 KB -