Submission #930948

# Submission time Handle Problem Language Result Execution time Memory
930948 2024-02-20T21:18:45 Z OAleksa Bootfall (IZhO17_bootfall) C++14
100 / 100
405 ms 32088 KB
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
const int N = 510;
const int A = 510;
bitset<250069> sf[N], sv, ans, pr[N], even, odd;
int n, a[N];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tt = 1;
  //cin >> tt;
  while (tt--) {
  	cin >> n;
  	sv[0] = 1;
  	for (int i = 1;i <= n;i++)
  		cin >> a[i], sv |= (sv << a[i]);
  	int s = accumulate(a + 1, a + n + 1, 0);
  	if (s % 2 == 1 || sv[s / 2] == 0) {
  		cout << '0';
  		return 0;
  	}
  	pr[0][0] = 1;
  	for (int i = 1;i <= n;i++) 
  		pr[i] = pr[i - 1] | (pr[i - 1] << a[i]);
  	sf[n + 1][0] = 1;
  	for (int i = n;i >= 1;i--)
  		sf[i] = sf[i + 1] | (sf[i + 1] << a[i]);
  	even.set();
  	odd.set();
		bitset<250069> cur;
		for (int i = 1;i <= n;i++) {
			if (i > n / 2) {
				cur = pr[i - 1];
				for (int j = i + 1;j <= n;j++)
					cur |= (cur << a[j]);
			}
			else {
				cur = sf[i + 1];
				for (int j = i - 1;j > 0;j--) 
					cur |= (cur << a[j]);
			}
			int l = s - a[i];
			if (l % 2 == 0) {
				//j mora bude parno
				even &= (cur >> (l / 2));
				odd &= 0;
			}
			else {
				odd &= (cur >> ((l + 1) / 2));
				even &= 0;
			}
		}
  	cout << even.count() + odd.count() << '\n';
  	for (int i = 0;i < 250069;i++) {
  		if (even[i])
  			cout << 2 * i << ' ';
  		else if (odd[i])
  			cout << 2 * i + 1 << ' ';
  	}
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 2 ms 4700 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 4652 KB Output is correct
5 Correct 2 ms 4648 KB Output is correct
6 Correct 1 ms 4744 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 2 ms 4700 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 2 ms 4700 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 4652 KB Output is correct
5 Correct 2 ms 4648 KB Output is correct
6 Correct 1 ms 4744 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 2 ms 4700 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 3 ms 4700 KB Output is correct
11 Correct 3 ms 4700 KB Output is correct
12 Correct 3 ms 4700 KB Output is correct
13 Correct 3 ms 4700 KB Output is correct
14 Correct 3 ms 4700 KB Output is correct
15 Correct 3 ms 4700 KB Output is correct
16 Correct 3 ms 4700 KB Output is correct
17 Correct 2 ms 4700 KB Output is correct
18 Correct 3 ms 4700 KB Output is correct
19 Correct 4 ms 4700 KB Output is correct
20 Correct 3 ms 4700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 2 ms 4700 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 4652 KB Output is correct
5 Correct 2 ms 4648 KB Output is correct
6 Correct 1 ms 4744 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 2 ms 4700 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 3 ms 4700 KB Output is correct
11 Correct 3 ms 4700 KB Output is correct
12 Correct 3 ms 4700 KB Output is correct
13 Correct 3 ms 4700 KB Output is correct
14 Correct 3 ms 4700 KB Output is correct
15 Correct 3 ms 4700 KB Output is correct
16 Correct 3 ms 4700 KB Output is correct
17 Correct 2 ms 4700 KB Output is correct
18 Correct 3 ms 4700 KB Output is correct
19 Correct 4 ms 4700 KB Output is correct
20 Correct 3 ms 4700 KB Output is correct
21 Correct 13 ms 5720 KB Output is correct
22 Correct 15 ms 8284 KB Output is correct
23 Correct 6 ms 5468 KB Output is correct
24 Correct 18 ms 8796 KB Output is correct
25 Correct 18 ms 8912 KB Output is correct
26 Correct 19 ms 9048 KB Output is correct
27 Correct 19 ms 9048 KB Output is correct
28 Correct 19 ms 9052 KB Output is correct
29 Correct 19 ms 9052 KB Output is correct
30 Correct 19 ms 9092 KB Output is correct
31 Correct 19 ms 9084 KB Output is correct
32 Correct 19 ms 9048 KB Output is correct
33 Correct 19 ms 9088 KB Output is correct
34 Correct 19 ms 9048 KB Output is correct
35 Correct 23 ms 9052 KB Output is correct
36 Correct 19 ms 9052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 2 ms 4700 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 4652 KB Output is correct
5 Correct 2 ms 4648 KB Output is correct
6 Correct 1 ms 4744 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 2 ms 4700 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 3 ms 4700 KB Output is correct
11 Correct 3 ms 4700 KB Output is correct
12 Correct 3 ms 4700 KB Output is correct
13 Correct 3 ms 4700 KB Output is correct
14 Correct 3 ms 4700 KB Output is correct
15 Correct 3 ms 4700 KB Output is correct
16 Correct 3 ms 4700 KB Output is correct
17 Correct 2 ms 4700 KB Output is correct
18 Correct 3 ms 4700 KB Output is correct
19 Correct 4 ms 4700 KB Output is correct
20 Correct 3 ms 4700 KB Output is correct
21 Correct 13 ms 5720 KB Output is correct
22 Correct 15 ms 8284 KB Output is correct
23 Correct 6 ms 5468 KB Output is correct
24 Correct 18 ms 8796 KB Output is correct
25 Correct 18 ms 8912 KB Output is correct
26 Correct 19 ms 9048 KB Output is correct
27 Correct 19 ms 9048 KB Output is correct
28 Correct 19 ms 9052 KB Output is correct
29 Correct 19 ms 9052 KB Output is correct
30 Correct 19 ms 9092 KB Output is correct
31 Correct 19 ms 9084 KB Output is correct
32 Correct 19 ms 9048 KB Output is correct
33 Correct 19 ms 9088 KB Output is correct
34 Correct 19 ms 9048 KB Output is correct
35 Correct 23 ms 9052 KB Output is correct
36 Correct 19 ms 9052 KB Output is correct
37 Correct 66 ms 14188 KB Output is correct
38 Correct 69 ms 14172 KB Output is correct
39 Correct 98 ms 17500 KB Output is correct
40 Correct 115 ms 18264 KB Output is correct
41 Correct 116 ms 18268 KB Output is correct
42 Correct 101 ms 17776 KB Output is correct
43 Correct 96 ms 17496 KB Output is correct
44 Correct 99 ms 17692 KB Output is correct
45 Correct 101 ms 17752 KB Output is correct
46 Correct 114 ms 18268 KB Output is correct
47 Correct 100 ms 17756 KB Output is correct
48 Correct 100 ms 17764 KB Output is correct
49 Correct 104 ms 17772 KB Output is correct
50 Correct 100 ms 17756 KB Output is correct
51 Correct 2 ms 2648 KB Output is correct
52 Correct 118 ms 18516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 2 ms 4700 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 4652 KB Output is correct
5 Correct 2 ms 4648 KB Output is correct
6 Correct 1 ms 4744 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 2 ms 4700 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 3 ms 4700 KB Output is correct
11 Correct 3 ms 4700 KB Output is correct
12 Correct 3 ms 4700 KB Output is correct
13 Correct 3 ms 4700 KB Output is correct
14 Correct 3 ms 4700 KB Output is correct
15 Correct 3 ms 4700 KB Output is correct
16 Correct 3 ms 4700 KB Output is correct
17 Correct 2 ms 4700 KB Output is correct
18 Correct 3 ms 4700 KB Output is correct
19 Correct 4 ms 4700 KB Output is correct
20 Correct 3 ms 4700 KB Output is correct
21 Correct 13 ms 5720 KB Output is correct
22 Correct 15 ms 8284 KB Output is correct
23 Correct 6 ms 5468 KB Output is correct
24 Correct 18 ms 8796 KB Output is correct
25 Correct 18 ms 8912 KB Output is correct
26 Correct 19 ms 9048 KB Output is correct
27 Correct 19 ms 9048 KB Output is correct
28 Correct 19 ms 9052 KB Output is correct
29 Correct 19 ms 9052 KB Output is correct
30 Correct 19 ms 9092 KB Output is correct
31 Correct 19 ms 9084 KB Output is correct
32 Correct 19 ms 9048 KB Output is correct
33 Correct 19 ms 9088 KB Output is correct
34 Correct 19 ms 9048 KB Output is correct
35 Correct 23 ms 9052 KB Output is correct
36 Correct 19 ms 9052 KB Output is correct
37 Correct 66 ms 14188 KB Output is correct
38 Correct 69 ms 14172 KB Output is correct
39 Correct 98 ms 17500 KB Output is correct
40 Correct 115 ms 18264 KB Output is correct
41 Correct 116 ms 18268 KB Output is correct
42 Correct 101 ms 17776 KB Output is correct
43 Correct 96 ms 17496 KB Output is correct
44 Correct 99 ms 17692 KB Output is correct
45 Correct 101 ms 17752 KB Output is correct
46 Correct 114 ms 18268 KB Output is correct
47 Correct 100 ms 17756 KB Output is correct
48 Correct 100 ms 17764 KB Output is correct
49 Correct 104 ms 17772 KB Output is correct
50 Correct 100 ms 17756 KB Output is correct
51 Correct 2 ms 2648 KB Output is correct
52 Correct 118 ms 18516 KB Output is correct
53 Correct 141 ms 21336 KB Output is correct
54 Correct 197 ms 24924 KB Output is correct
55 Correct 223 ms 25420 KB Output is correct
56 Correct 146 ms 21588 KB Output is correct
57 Correct 192 ms 25172 KB Output is correct
58 Correct 194 ms 25428 KB Output is correct
59 Correct 190 ms 24928 KB Output is correct
60 Correct 3 ms 2396 KB Output is correct
61 Correct 193 ms 24940 KB Output is correct
62 Correct 163 ms 22096 KB Output is correct
63 Correct 161 ms 22204 KB Output is correct
64 Correct 155 ms 22028 KB Output is correct
65 Correct 155 ms 21592 KB Output is correct
66 Correct 162 ms 21596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 2 ms 4700 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 4652 KB Output is correct
5 Correct 2 ms 4648 KB Output is correct
6 Correct 1 ms 4744 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 2 ms 4700 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 3 ms 4700 KB Output is correct
11 Correct 3 ms 4700 KB Output is correct
12 Correct 3 ms 4700 KB Output is correct
13 Correct 3 ms 4700 KB Output is correct
14 Correct 3 ms 4700 KB Output is correct
15 Correct 3 ms 4700 KB Output is correct
16 Correct 3 ms 4700 KB Output is correct
17 Correct 2 ms 4700 KB Output is correct
18 Correct 3 ms 4700 KB Output is correct
19 Correct 4 ms 4700 KB Output is correct
20 Correct 3 ms 4700 KB Output is correct
21 Correct 13 ms 5720 KB Output is correct
22 Correct 15 ms 8284 KB Output is correct
23 Correct 6 ms 5468 KB Output is correct
24 Correct 18 ms 8796 KB Output is correct
25 Correct 18 ms 8912 KB Output is correct
26 Correct 19 ms 9048 KB Output is correct
27 Correct 19 ms 9048 KB Output is correct
28 Correct 19 ms 9052 KB Output is correct
29 Correct 19 ms 9052 KB Output is correct
30 Correct 19 ms 9092 KB Output is correct
31 Correct 19 ms 9084 KB Output is correct
32 Correct 19 ms 9048 KB Output is correct
33 Correct 19 ms 9088 KB Output is correct
34 Correct 19 ms 9048 KB Output is correct
35 Correct 23 ms 9052 KB Output is correct
36 Correct 19 ms 9052 KB Output is correct
37 Correct 66 ms 14188 KB Output is correct
38 Correct 69 ms 14172 KB Output is correct
39 Correct 98 ms 17500 KB Output is correct
40 Correct 115 ms 18264 KB Output is correct
41 Correct 116 ms 18268 KB Output is correct
42 Correct 101 ms 17776 KB Output is correct
43 Correct 96 ms 17496 KB Output is correct
44 Correct 99 ms 17692 KB Output is correct
45 Correct 101 ms 17752 KB Output is correct
46 Correct 114 ms 18268 KB Output is correct
47 Correct 100 ms 17756 KB Output is correct
48 Correct 100 ms 17764 KB Output is correct
49 Correct 104 ms 17772 KB Output is correct
50 Correct 100 ms 17756 KB Output is correct
51 Correct 2 ms 2648 KB Output is correct
52 Correct 118 ms 18516 KB Output is correct
53 Correct 141 ms 21336 KB Output is correct
54 Correct 197 ms 24924 KB Output is correct
55 Correct 223 ms 25420 KB Output is correct
56 Correct 146 ms 21588 KB Output is correct
57 Correct 192 ms 25172 KB Output is correct
58 Correct 194 ms 25428 KB Output is correct
59 Correct 190 ms 24928 KB Output is correct
60 Correct 3 ms 2396 KB Output is correct
61 Correct 193 ms 24940 KB Output is correct
62 Correct 163 ms 22096 KB Output is correct
63 Correct 161 ms 22204 KB Output is correct
64 Correct 155 ms 22028 KB Output is correct
65 Correct 155 ms 21592 KB Output is correct
66 Correct 162 ms 21596 KB Output is correct
67 Correct 247 ms 26456 KB Output is correct
68 Correct 4 ms 2396 KB Output is correct
69 Correct 405 ms 32088 KB Output is correct
70 Correct 392 ms 31816 KB Output is correct
71 Correct 386 ms 31824 KB Output is correct
72 Correct 379 ms 31580 KB Output is correct
73 Correct 376 ms 31528 KB Output is correct
74 Correct 377 ms 32080 KB Output is correct
75 Correct 386 ms 32024 KB Output is correct
76 Correct 380 ms 32072 KB Output is correct
77 Correct 388 ms 32080 KB Output is correct