Submission #233715

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

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

bitset<S> ans;

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++) {
   // i = n;
    int was = a[i];    
    a[i] = 0;
    whole_sum -= was;
    bitset<S> is_possible;
    is_possible[0] = 1;
    for (int j = 0; j < n; j++) {
      is_possible |= (is_possible << a[j]);
    }
    bitset<S> Get;
    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 13 ms 512 KB Output is correct
11 Correct 12 ms 384 KB Output is correct
12 Correct 13 ms 384 KB Output is correct
13 Correct 10 ms 384 KB Output is correct
14 Correct 12 ms 384 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 384 KB Output is correct
20 Correct 13 ms 384 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 13 ms 512 KB Output is correct
11 Correct 12 ms 384 KB Output is correct
12 Correct 13 ms 384 KB Output is correct
13 Correct 10 ms 384 KB Output is correct
14 Correct 12 ms 384 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 384 KB Output is correct
20 Correct 13 ms 384 KB Output is correct
21 Correct 41 ms 504 KB Output is correct
22 Correct 53 ms 504 KB Output is correct
23 Correct 27 ms 512 KB Output is correct
24 Correct 81 ms 504 KB Output is correct
25 Correct 87 ms 504 KB Output is correct
26 Correct 98 ms 504 KB Output is correct
27 Correct 91 ms 504 KB Output is correct
28 Correct 94 ms 504 KB Output is correct
29 Correct 93 ms 512 KB Output is correct
30 Correct 94 ms 512 KB Output is correct
31 Correct 98 ms 504 KB Output is correct
32 Correct 95 ms 504 KB Output is correct
33 Correct 96 ms 504 KB Output is correct
34 Correct 98 ms 512 KB Output is correct
35 Correct 98 ms 504 KB Output is correct
36 Correct 97 ms 504 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 13 ms 512 KB Output is correct
11 Correct 12 ms 384 KB Output is correct
12 Correct 13 ms 384 KB Output is correct
13 Correct 10 ms 384 KB Output is correct
14 Correct 12 ms 384 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 384 KB Output is correct
20 Correct 13 ms 384 KB Output is correct
21 Correct 41 ms 504 KB Output is correct
22 Correct 53 ms 504 KB Output is correct
23 Correct 27 ms 512 KB Output is correct
24 Correct 81 ms 504 KB Output is correct
25 Correct 87 ms 504 KB Output is correct
26 Correct 98 ms 504 KB Output is correct
27 Correct 91 ms 504 KB Output is correct
28 Correct 94 ms 504 KB Output is correct
29 Correct 93 ms 512 KB Output is correct
30 Correct 94 ms 512 KB Output is correct
31 Correct 98 ms 504 KB Output is correct
32 Correct 95 ms 504 KB Output is correct
33 Correct 96 ms 504 KB Output is correct
34 Correct 98 ms 512 KB Output is correct
35 Correct 98 ms 504 KB Output is correct
36 Correct 97 ms 504 KB Output is correct
37 Correct 368 ms 504 KB Output is correct
38 Correct 373 ms 504 KB Output is correct
39 Correct 584 ms 504 KB Output is correct
40 Correct 667 ms 632 KB Output is correct
41 Correct 683 ms 384 KB Output is correct
42 Correct 557 ms 504 KB Output is correct
43 Correct 572 ms 632 KB Output is correct
44 Correct 592 ms 632 KB Output is correct
45 Correct 587 ms 632 KB Output is correct
46 Correct 651 ms 504 KB Output is correct
47 Correct 589 ms 636 KB Output is correct
48 Correct 593 ms 504 KB Output is correct
49 Correct 606 ms 504 KB Output is correct
50 Correct 604 ms 504 KB Output is correct
51 Correct 596 ms 384 KB Output is correct
52 Correct 689 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 13 ms 512 KB Output is correct
11 Correct 12 ms 384 KB Output is correct
12 Correct 13 ms 384 KB Output is correct
13 Correct 10 ms 384 KB Output is correct
14 Correct 12 ms 384 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 384 KB Output is correct
20 Correct 13 ms 384 KB Output is correct
21 Correct 41 ms 504 KB Output is correct
22 Correct 53 ms 504 KB Output is correct
23 Correct 27 ms 512 KB Output is correct
24 Correct 81 ms 504 KB Output is correct
25 Correct 87 ms 504 KB Output is correct
26 Correct 98 ms 504 KB Output is correct
27 Correct 91 ms 504 KB Output is correct
28 Correct 94 ms 504 KB Output is correct
29 Correct 93 ms 512 KB Output is correct
30 Correct 94 ms 512 KB Output is correct
31 Correct 98 ms 504 KB Output is correct
32 Correct 95 ms 504 KB Output is correct
33 Correct 96 ms 504 KB Output is correct
34 Correct 98 ms 512 KB Output is correct
35 Correct 98 ms 504 KB Output is correct
36 Correct 97 ms 504 KB Output is correct
37 Correct 368 ms 504 KB Output is correct
38 Correct 373 ms 504 KB Output is correct
39 Correct 584 ms 504 KB Output is correct
40 Correct 667 ms 632 KB Output is correct
41 Correct 683 ms 384 KB Output is correct
42 Correct 557 ms 504 KB Output is correct
43 Correct 572 ms 632 KB Output is correct
44 Correct 592 ms 632 KB Output is correct
45 Correct 587 ms 632 KB Output is correct
46 Correct 651 ms 504 KB Output is correct
47 Correct 589 ms 636 KB Output is correct
48 Correct 593 ms 504 KB Output is correct
49 Correct 606 ms 504 KB Output is correct
50 Correct 604 ms 504 KB Output is correct
51 Correct 596 ms 384 KB Output is correct
52 Correct 689 ms 632 KB Output is correct
53 Correct 814 ms 632 KB Output is correct
54 Execution timed out 1045 ms 384 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 13 ms 512 KB Output is correct
11 Correct 12 ms 384 KB Output is correct
12 Correct 13 ms 384 KB Output is correct
13 Correct 10 ms 384 KB Output is correct
14 Correct 12 ms 384 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 384 KB Output is correct
20 Correct 13 ms 384 KB Output is correct
21 Correct 41 ms 504 KB Output is correct
22 Correct 53 ms 504 KB Output is correct
23 Correct 27 ms 512 KB Output is correct
24 Correct 81 ms 504 KB Output is correct
25 Correct 87 ms 504 KB Output is correct
26 Correct 98 ms 504 KB Output is correct
27 Correct 91 ms 504 KB Output is correct
28 Correct 94 ms 504 KB Output is correct
29 Correct 93 ms 512 KB Output is correct
30 Correct 94 ms 512 KB Output is correct
31 Correct 98 ms 504 KB Output is correct
32 Correct 95 ms 504 KB Output is correct
33 Correct 96 ms 504 KB Output is correct
34 Correct 98 ms 512 KB Output is correct
35 Correct 98 ms 504 KB Output is correct
36 Correct 97 ms 504 KB Output is correct
37 Correct 368 ms 504 KB Output is correct
38 Correct 373 ms 504 KB Output is correct
39 Correct 584 ms 504 KB Output is correct
40 Correct 667 ms 632 KB Output is correct
41 Correct 683 ms 384 KB Output is correct
42 Correct 557 ms 504 KB Output is correct
43 Correct 572 ms 632 KB Output is correct
44 Correct 592 ms 632 KB Output is correct
45 Correct 587 ms 632 KB Output is correct
46 Correct 651 ms 504 KB Output is correct
47 Correct 589 ms 636 KB Output is correct
48 Correct 593 ms 504 KB Output is correct
49 Correct 606 ms 504 KB Output is correct
50 Correct 604 ms 504 KB Output is correct
51 Correct 596 ms 384 KB Output is correct
52 Correct 689 ms 632 KB Output is correct
53 Correct 814 ms 632 KB Output is correct
54 Execution timed out 1045 ms 384 KB Time limit exceeded
55 Halted 0 ms 0 KB -