Submission #506583

# Submission time Handle Problem Language Result Execution time Memory
506583 2022-01-12T05:49:42 Z abc864197532 Bootfall (IZhO17_bootfall) C++17
65 / 100
1000 ms 1636 KB
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define X first
#define Y second
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
void abc() {cout << endl;}
template <typename T, typename ...U> void abc(T i, U ...j) {
	cout << i << ' ', abc(j...);
}
template <typename T> void printv(T l, T r) {
	for (; l != r; ++l)
		cout << *l << " \n"[l + 1 == r];
}
#define test(x...) abc("[" + string(#x) + "]", x);
const int N = 500 * 500 + 5;

bitset <N> dp;

int main () {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector <int> a(n);
	int sum = 0;
	dp.flip(0);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		sum += a[i];
		dp |= dp << a[i];
	}
	if (sum & 1 || !dp[sum >> 1]) {
		cout << 0 << endl << endl;
	} else {
		vector <int> ans(N, 0);
		for (int i = 0; i < n; ++i) {
			sum -= a[i];
			dp.reset(), dp.flip(0);
			for (int j = 0; j < n; ++j) if (i != j)
				dp |= dp << a[j];
			for (int j = 0; j <= sum / 2; ++j) if (dp[j]) 
				ans[abs(sum - j - j)]++;
			sum += a[i];
		}
		int cnt = 0;
		for (int i : ans) if (i == n)
			cnt++;
		cout << cnt << endl;
		for (int i = 0; i < N; ++i) if (ans[i] == n)
			cout << i << ' ';
		cout << endl;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1348 KB Output is correct
2 Correct 2 ms 1404 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 1272 KB Output is correct
5 Correct 2 ms 1356 KB Output is correct
6 Correct 2 ms 1356 KB Output is correct
7 Correct 1 ms 1356 KB Output is correct
8 Correct 2 ms 1356 KB Output is correct
9 Correct 2 ms 1268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1348 KB Output is correct
2 Correct 2 ms 1404 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 1272 KB Output is correct
5 Correct 2 ms 1356 KB Output is correct
6 Correct 2 ms 1356 KB Output is correct
7 Correct 1 ms 1356 KB Output is correct
8 Correct 2 ms 1356 KB Output is correct
9 Correct 2 ms 1268 KB Output is correct
10 Correct 8 ms 1356 KB Output is correct
11 Correct 7 ms 1396 KB Output is correct
12 Correct 7 ms 1356 KB Output is correct
13 Correct 7 ms 1356 KB Output is correct
14 Correct 7 ms 1296 KB Output is correct
15 Correct 7 ms 1396 KB Output is correct
16 Correct 9 ms 1396 KB Output is correct
17 Correct 4 ms 1356 KB Output is correct
18 Correct 5 ms 1356 KB Output is correct
19 Correct 6 ms 1356 KB Output is correct
20 Correct 8 ms 1484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1348 KB Output is correct
2 Correct 2 ms 1404 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 1272 KB Output is correct
5 Correct 2 ms 1356 KB Output is correct
6 Correct 2 ms 1356 KB Output is correct
7 Correct 1 ms 1356 KB Output is correct
8 Correct 2 ms 1356 KB Output is correct
9 Correct 2 ms 1268 KB Output is correct
10 Correct 8 ms 1356 KB Output is correct
11 Correct 7 ms 1396 KB Output is correct
12 Correct 7 ms 1356 KB Output is correct
13 Correct 7 ms 1356 KB Output is correct
14 Correct 7 ms 1296 KB Output is correct
15 Correct 7 ms 1396 KB Output is correct
16 Correct 9 ms 1396 KB Output is correct
17 Correct 4 ms 1356 KB Output is correct
18 Correct 5 ms 1356 KB Output is correct
19 Correct 6 ms 1356 KB Output is correct
20 Correct 8 ms 1484 KB Output is correct
21 Correct 31 ms 1372 KB Output is correct
22 Correct 40 ms 1376 KB Output is correct
23 Correct 19 ms 1392 KB Output is correct
24 Correct 64 ms 1376 KB Output is correct
25 Correct 66 ms 1372 KB Output is correct
26 Correct 72 ms 1356 KB Output is correct
27 Correct 77 ms 1392 KB Output is correct
28 Correct 91 ms 1372 KB Output is correct
29 Correct 83 ms 1384 KB Output is correct
30 Correct 83 ms 1356 KB Output is correct
31 Correct 74 ms 1356 KB Output is correct
32 Correct 72 ms 1392 KB Output is correct
33 Correct 72 ms 1376 KB Output is correct
34 Correct 84 ms 1356 KB Output is correct
35 Correct 78 ms 1376 KB Output is correct
36 Correct 76 ms 1388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1348 KB Output is correct
2 Correct 2 ms 1404 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 1272 KB Output is correct
5 Correct 2 ms 1356 KB Output is correct
6 Correct 2 ms 1356 KB Output is correct
7 Correct 1 ms 1356 KB Output is correct
8 Correct 2 ms 1356 KB Output is correct
9 Correct 2 ms 1268 KB Output is correct
10 Correct 8 ms 1356 KB Output is correct
11 Correct 7 ms 1396 KB Output is correct
12 Correct 7 ms 1356 KB Output is correct
13 Correct 7 ms 1356 KB Output is correct
14 Correct 7 ms 1296 KB Output is correct
15 Correct 7 ms 1396 KB Output is correct
16 Correct 9 ms 1396 KB Output is correct
17 Correct 4 ms 1356 KB Output is correct
18 Correct 5 ms 1356 KB Output is correct
19 Correct 6 ms 1356 KB Output is correct
20 Correct 8 ms 1484 KB Output is correct
21 Correct 31 ms 1372 KB Output is correct
22 Correct 40 ms 1376 KB Output is correct
23 Correct 19 ms 1392 KB Output is correct
24 Correct 64 ms 1376 KB Output is correct
25 Correct 66 ms 1372 KB Output is correct
26 Correct 72 ms 1356 KB Output is correct
27 Correct 77 ms 1392 KB Output is correct
28 Correct 91 ms 1372 KB Output is correct
29 Correct 83 ms 1384 KB Output is correct
30 Correct 83 ms 1356 KB Output is correct
31 Correct 74 ms 1356 KB Output is correct
32 Correct 72 ms 1392 KB Output is correct
33 Correct 72 ms 1376 KB Output is correct
34 Correct 84 ms 1356 KB Output is correct
35 Correct 78 ms 1376 KB Output is correct
36 Correct 76 ms 1388 KB Output is correct
37 Correct 317 ms 1376 KB Output is correct
38 Correct 287 ms 1376 KB Output is correct
39 Correct 458 ms 1388 KB Output is correct
40 Correct 529 ms 1376 KB Output is correct
41 Correct 586 ms 1356 KB Output is correct
42 Correct 465 ms 1372 KB Output is correct
43 Correct 480 ms 1508 KB Output is correct
44 Correct 464 ms 1512 KB Output is correct
45 Correct 460 ms 1508 KB Output is correct
46 Correct 546 ms 1356 KB Output is correct
47 Correct 504 ms 1380 KB Output is correct
48 Correct 472 ms 1372 KB Output is correct
49 Correct 509 ms 1484 KB Output is correct
50 Correct 482 ms 1380 KB Output is correct
51 Correct 3 ms 332 KB Output is correct
52 Correct 611 ms 1496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1348 KB Output is correct
2 Correct 2 ms 1404 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 1272 KB Output is correct
5 Correct 2 ms 1356 KB Output is correct
6 Correct 2 ms 1356 KB Output is correct
7 Correct 1 ms 1356 KB Output is correct
8 Correct 2 ms 1356 KB Output is correct
9 Correct 2 ms 1268 KB Output is correct
10 Correct 8 ms 1356 KB Output is correct
11 Correct 7 ms 1396 KB Output is correct
12 Correct 7 ms 1356 KB Output is correct
13 Correct 7 ms 1356 KB Output is correct
14 Correct 7 ms 1296 KB Output is correct
15 Correct 7 ms 1396 KB Output is correct
16 Correct 9 ms 1396 KB Output is correct
17 Correct 4 ms 1356 KB Output is correct
18 Correct 5 ms 1356 KB Output is correct
19 Correct 6 ms 1356 KB Output is correct
20 Correct 8 ms 1484 KB Output is correct
21 Correct 31 ms 1372 KB Output is correct
22 Correct 40 ms 1376 KB Output is correct
23 Correct 19 ms 1392 KB Output is correct
24 Correct 64 ms 1376 KB Output is correct
25 Correct 66 ms 1372 KB Output is correct
26 Correct 72 ms 1356 KB Output is correct
27 Correct 77 ms 1392 KB Output is correct
28 Correct 91 ms 1372 KB Output is correct
29 Correct 83 ms 1384 KB Output is correct
30 Correct 83 ms 1356 KB Output is correct
31 Correct 74 ms 1356 KB Output is correct
32 Correct 72 ms 1392 KB Output is correct
33 Correct 72 ms 1376 KB Output is correct
34 Correct 84 ms 1356 KB Output is correct
35 Correct 78 ms 1376 KB Output is correct
36 Correct 76 ms 1388 KB Output is correct
37 Correct 317 ms 1376 KB Output is correct
38 Correct 287 ms 1376 KB Output is correct
39 Correct 458 ms 1388 KB Output is correct
40 Correct 529 ms 1376 KB Output is correct
41 Correct 586 ms 1356 KB Output is correct
42 Correct 465 ms 1372 KB Output is correct
43 Correct 480 ms 1508 KB Output is correct
44 Correct 464 ms 1512 KB Output is correct
45 Correct 460 ms 1508 KB Output is correct
46 Correct 546 ms 1356 KB Output is correct
47 Correct 504 ms 1380 KB Output is correct
48 Correct 472 ms 1372 KB Output is correct
49 Correct 509 ms 1484 KB Output is correct
50 Correct 482 ms 1380 KB Output is correct
51 Correct 3 ms 332 KB Output is correct
52 Correct 611 ms 1496 KB Output is correct
53 Correct 754 ms 1500 KB Output is correct
54 Correct 928 ms 1500 KB Output is correct
55 Correct 959 ms 1636 KB Output is correct
56 Correct 722 ms 1500 KB Output is correct
57 Correct 954 ms 1632 KB Output is correct
58 Correct 902 ms 1508 KB Output is correct
59 Correct 946 ms 1500 KB Output is correct
60 Correct 3 ms 332 KB Output is correct
61 Correct 946 ms 1496 KB Output is correct
62 Correct 839 ms 1632 KB Output is correct
63 Correct 905 ms 1632 KB Output is correct
64 Correct 810 ms 1632 KB Output is correct
65 Correct 791 ms 1376 KB Output is correct
66 Correct 803 ms 1372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1348 KB Output is correct
2 Correct 2 ms 1404 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 1272 KB Output is correct
5 Correct 2 ms 1356 KB Output is correct
6 Correct 2 ms 1356 KB Output is correct
7 Correct 1 ms 1356 KB Output is correct
8 Correct 2 ms 1356 KB Output is correct
9 Correct 2 ms 1268 KB Output is correct
10 Correct 8 ms 1356 KB Output is correct
11 Correct 7 ms 1396 KB Output is correct
12 Correct 7 ms 1356 KB Output is correct
13 Correct 7 ms 1356 KB Output is correct
14 Correct 7 ms 1296 KB Output is correct
15 Correct 7 ms 1396 KB Output is correct
16 Correct 9 ms 1396 KB Output is correct
17 Correct 4 ms 1356 KB Output is correct
18 Correct 5 ms 1356 KB Output is correct
19 Correct 6 ms 1356 KB Output is correct
20 Correct 8 ms 1484 KB Output is correct
21 Correct 31 ms 1372 KB Output is correct
22 Correct 40 ms 1376 KB Output is correct
23 Correct 19 ms 1392 KB Output is correct
24 Correct 64 ms 1376 KB Output is correct
25 Correct 66 ms 1372 KB Output is correct
26 Correct 72 ms 1356 KB Output is correct
27 Correct 77 ms 1392 KB Output is correct
28 Correct 91 ms 1372 KB Output is correct
29 Correct 83 ms 1384 KB Output is correct
30 Correct 83 ms 1356 KB Output is correct
31 Correct 74 ms 1356 KB Output is correct
32 Correct 72 ms 1392 KB Output is correct
33 Correct 72 ms 1376 KB Output is correct
34 Correct 84 ms 1356 KB Output is correct
35 Correct 78 ms 1376 KB Output is correct
36 Correct 76 ms 1388 KB Output is correct
37 Correct 317 ms 1376 KB Output is correct
38 Correct 287 ms 1376 KB Output is correct
39 Correct 458 ms 1388 KB Output is correct
40 Correct 529 ms 1376 KB Output is correct
41 Correct 586 ms 1356 KB Output is correct
42 Correct 465 ms 1372 KB Output is correct
43 Correct 480 ms 1508 KB Output is correct
44 Correct 464 ms 1512 KB Output is correct
45 Correct 460 ms 1508 KB Output is correct
46 Correct 546 ms 1356 KB Output is correct
47 Correct 504 ms 1380 KB Output is correct
48 Correct 472 ms 1372 KB Output is correct
49 Correct 509 ms 1484 KB Output is correct
50 Correct 482 ms 1380 KB Output is correct
51 Correct 3 ms 332 KB Output is correct
52 Correct 611 ms 1496 KB Output is correct
53 Correct 754 ms 1500 KB Output is correct
54 Correct 928 ms 1500 KB Output is correct
55 Correct 959 ms 1636 KB Output is correct
56 Correct 722 ms 1500 KB Output is correct
57 Correct 954 ms 1632 KB Output is correct
58 Correct 902 ms 1508 KB Output is correct
59 Correct 946 ms 1500 KB Output is correct
60 Correct 3 ms 332 KB Output is correct
61 Correct 946 ms 1496 KB Output is correct
62 Correct 839 ms 1632 KB Output is correct
63 Correct 905 ms 1632 KB Output is correct
64 Correct 810 ms 1632 KB Output is correct
65 Correct 791 ms 1376 KB Output is correct
66 Correct 803 ms 1372 KB Output is correct
67 Execution timed out 1069 ms 1264 KB Time limit exceeded
68 Halted 0 ms 0 KB -