Submission #879612

# Submission time Handle Problem Language Result Execution time Memory
879612 2023-11-27T18:01:21 Z alex_2008 Bootfall (IZhO17_bootfall) C++14
65 / 100
1000 ms 100048 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <unordered_set>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <fstream>
#include <random>
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
const int N = 510;
const int M = 251000;
int a[N];
bitset <M> b[N];
bool ch[N][2 * M];
int main() {
	int n, sm = 0;
	cin >> n;
	bitset <M> w;
	w[0] = 1;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (a[i] % 2 != a[1] % 2) {
			cout << "0\n";
			return 0;
		}
		w |= (w << a[i]);
		sm += a[i];
	}
	if (sm % 2 == 1) {
		cout << "0\n";
		return 0;
	}
	if (!w[sm / 2]) {
		cout << "0\n";
		return 0;
	}
	for (int i = 1; i <= n; i++) {
		b[i][0] = 1;
		for (int j = 1; j <= n; j++) {
			if (i == j) continue;
			b[i] |= (b[i] << a[j]);
		}
	}
	for (int i = 1; i <= n; i++) {
		sm -= a[i];
		for (int j = 0; j <= sm; j++) {
			if (b[i][j]) {
				if (2 * j < sm) {
					ch[i][sm - 2 * j] = true;
				}
				else {
					ch[i][2 * j - sm] = true;
				}
			}
		}
		sm += a[i];
	}
	vector <int> ans;
	for (int j = 1; j <= 250000; j++) {
		bool flag = true;
		for (int i = 1; i <= n; i++) {
			if (ch[i][j]) continue;
			flag = false; break;
		}
		if (flag) ans.push_back(j);
	}
	cout << (int)ans.size() << "\n";
	for (auto it : ans) {
		cout << it << " ";
	}
	cout << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Correct 1 ms 428 KB Output is correct
4 Correct 2 ms 4696 KB Output is correct
5 Correct 3 ms 8536 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6676 KB Output is correct
8 Correct 3 ms 8540 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Correct 1 ms 428 KB Output is correct
4 Correct 2 ms 4696 KB Output is correct
5 Correct 3 ms 8536 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6676 KB Output is correct
8 Correct 3 ms 8540 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 10 ms 18984 KB Output is correct
11 Correct 8 ms 18972 KB Output is correct
12 Correct 9 ms 18780 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 7 ms 16732 KB Output is correct
15 Correct 7 ms 16732 KB Output is correct
16 Correct 8 ms 18780 KB Output is correct
17 Correct 5 ms 12636 KB Output is correct
18 Correct 6 ms 14684 KB Output is correct
19 Correct 7 ms 16920 KB Output is correct
20 Correct 9 ms 18780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Correct 1 ms 428 KB Output is correct
4 Correct 2 ms 4696 KB Output is correct
5 Correct 3 ms 8536 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6676 KB Output is correct
8 Correct 3 ms 8540 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 10 ms 18984 KB Output is correct
11 Correct 8 ms 18972 KB Output is correct
12 Correct 9 ms 18780 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 7 ms 16732 KB Output is correct
15 Correct 7 ms 16732 KB Output is correct
16 Correct 8 ms 18780 KB Output is correct
17 Correct 5 ms 12636 KB Output is correct
18 Correct 6 ms 14684 KB Output is correct
19 Correct 7 ms 16920 KB Output is correct
20 Correct 9 ms 18780 KB Output is correct
21 Correct 30 ms 35360 KB Output is correct
22 Correct 38 ms 39676 KB Output is correct
23 Correct 19 ms 26972 KB Output is correct
24 Correct 57 ms 50528 KB Output is correct
25 Correct 70 ms 50436 KB Output is correct
26 Correct 65 ms 52816 KB Output is correct
27 Correct 64 ms 52800 KB Output is correct
28 Correct 66 ms 52748 KB Output is correct
29 Correct 65 ms 48720 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 64 ms 52756 KB Output is correct
32 Correct 66 ms 52764 KB Output is correct
33 Correct 63 ms 50704 KB Output is correct
34 Correct 67 ms 52740 KB Output is correct
35 Correct 66 ms 52828 KB Output is correct
36 Correct 65 ms 52804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Correct 1 ms 428 KB Output is correct
4 Correct 2 ms 4696 KB Output is correct
5 Correct 3 ms 8536 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6676 KB Output is correct
8 Correct 3 ms 8540 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 10 ms 18984 KB Output is correct
11 Correct 8 ms 18972 KB Output is correct
12 Correct 9 ms 18780 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 7 ms 16732 KB Output is correct
15 Correct 7 ms 16732 KB Output is correct
16 Correct 8 ms 18780 KB Output is correct
17 Correct 5 ms 12636 KB Output is correct
18 Correct 6 ms 14684 KB Output is correct
19 Correct 7 ms 16920 KB Output is correct
20 Correct 9 ms 18780 KB Output is correct
21 Correct 30 ms 35360 KB Output is correct
22 Correct 38 ms 39676 KB Output is correct
23 Correct 19 ms 26972 KB Output is correct
24 Correct 57 ms 50528 KB Output is correct
25 Correct 70 ms 50436 KB Output is correct
26 Correct 65 ms 52816 KB Output is correct
27 Correct 64 ms 52800 KB Output is correct
28 Correct 66 ms 52748 KB Output is correct
29 Correct 65 ms 48720 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 64 ms 52756 KB Output is correct
32 Correct 66 ms 52764 KB Output is correct
33 Correct 63 ms 50704 KB Output is correct
34 Correct 67 ms 52740 KB Output is correct
35 Correct 66 ms 52828 KB Output is correct
36 Correct 65 ms 52804 KB Output is correct
37 Correct 264 ms 56336 KB Output is correct
38 Correct 249 ms 62480 KB Output is correct
39 Correct 372 ms 70400 KB Output is correct
40 Correct 460 ms 68292 KB Output is correct
41 Correct 458 ms 75940 KB Output is correct
42 Correct 401 ms 74240 KB Output is correct
43 Correct 372 ms 69660 KB Output is correct
44 Correct 406 ms 69980 KB Output is correct
45 Correct 392 ms 73812 KB Output is correct
46 Correct 459 ms 71672 KB Output is correct
47 Correct 390 ms 67024 KB Output is correct
48 Correct 434 ms 72592 KB Output is correct
49 Correct 521 ms 70848 KB Output is correct
50 Correct 377 ms 66820 KB Output is correct
51 Correct 0 ms 344 KB Output is correct
52 Correct 475 ms 74388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Correct 1 ms 428 KB Output is correct
4 Correct 2 ms 4696 KB Output is correct
5 Correct 3 ms 8536 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6676 KB Output is correct
8 Correct 3 ms 8540 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 10 ms 18984 KB Output is correct
11 Correct 8 ms 18972 KB Output is correct
12 Correct 9 ms 18780 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 7 ms 16732 KB Output is correct
15 Correct 7 ms 16732 KB Output is correct
16 Correct 8 ms 18780 KB Output is correct
17 Correct 5 ms 12636 KB Output is correct
18 Correct 6 ms 14684 KB Output is correct
19 Correct 7 ms 16920 KB Output is correct
20 Correct 9 ms 18780 KB Output is correct
21 Correct 30 ms 35360 KB Output is correct
22 Correct 38 ms 39676 KB Output is correct
23 Correct 19 ms 26972 KB Output is correct
24 Correct 57 ms 50528 KB Output is correct
25 Correct 70 ms 50436 KB Output is correct
26 Correct 65 ms 52816 KB Output is correct
27 Correct 64 ms 52800 KB Output is correct
28 Correct 66 ms 52748 KB Output is correct
29 Correct 65 ms 48720 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 64 ms 52756 KB Output is correct
32 Correct 66 ms 52764 KB Output is correct
33 Correct 63 ms 50704 KB Output is correct
34 Correct 67 ms 52740 KB Output is correct
35 Correct 66 ms 52828 KB Output is correct
36 Correct 65 ms 52804 KB Output is correct
37 Correct 264 ms 56336 KB Output is correct
38 Correct 249 ms 62480 KB Output is correct
39 Correct 372 ms 70400 KB Output is correct
40 Correct 460 ms 68292 KB Output is correct
41 Correct 458 ms 75940 KB Output is correct
42 Correct 401 ms 74240 KB Output is correct
43 Correct 372 ms 69660 KB Output is correct
44 Correct 406 ms 69980 KB Output is correct
45 Correct 392 ms 73812 KB Output is correct
46 Correct 459 ms 71672 KB Output is correct
47 Correct 390 ms 67024 KB Output is correct
48 Correct 434 ms 72592 KB Output is correct
49 Correct 521 ms 70848 KB Output is correct
50 Correct 377 ms 66820 KB Output is correct
51 Correct 0 ms 344 KB Output is correct
52 Correct 475 ms 74388 KB Output is correct
53 Correct 548 ms 69168 KB Output is correct
54 Correct 762 ms 77288 KB Output is correct
55 Correct 817 ms 92596 KB Output is correct
56 Correct 608 ms 78900 KB Output is correct
57 Correct 812 ms 100048 KB Output is correct
58 Correct 785 ms 89536 KB Output is correct
59 Correct 759 ms 89272 KB Output is correct
60 Correct 0 ms 344 KB Output is correct
61 Correct 774 ms 93072 KB Output is correct
62 Correct 675 ms 89732 KB Output is correct
63 Correct 650 ms 88272 KB Output is correct
64 Correct 641 ms 86948 KB Output is correct
65 Correct 593 ms 79824 KB Output is correct
66 Correct 609 ms 80300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Correct 1 ms 428 KB Output is correct
4 Correct 2 ms 4696 KB Output is correct
5 Correct 3 ms 8536 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6676 KB Output is correct
8 Correct 3 ms 8540 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 10 ms 18984 KB Output is correct
11 Correct 8 ms 18972 KB Output is correct
12 Correct 9 ms 18780 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 7 ms 16732 KB Output is correct
15 Correct 7 ms 16732 KB Output is correct
16 Correct 8 ms 18780 KB Output is correct
17 Correct 5 ms 12636 KB Output is correct
18 Correct 6 ms 14684 KB Output is correct
19 Correct 7 ms 16920 KB Output is correct
20 Correct 9 ms 18780 KB Output is correct
21 Correct 30 ms 35360 KB Output is correct
22 Correct 38 ms 39676 KB Output is correct
23 Correct 19 ms 26972 KB Output is correct
24 Correct 57 ms 50528 KB Output is correct
25 Correct 70 ms 50436 KB Output is correct
26 Correct 65 ms 52816 KB Output is correct
27 Correct 64 ms 52800 KB Output is correct
28 Correct 66 ms 52748 KB Output is correct
29 Correct 65 ms 48720 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 64 ms 52756 KB Output is correct
32 Correct 66 ms 52764 KB Output is correct
33 Correct 63 ms 50704 KB Output is correct
34 Correct 67 ms 52740 KB Output is correct
35 Correct 66 ms 52828 KB Output is correct
36 Correct 65 ms 52804 KB Output is correct
37 Correct 264 ms 56336 KB Output is correct
38 Correct 249 ms 62480 KB Output is correct
39 Correct 372 ms 70400 KB Output is correct
40 Correct 460 ms 68292 KB Output is correct
41 Correct 458 ms 75940 KB Output is correct
42 Correct 401 ms 74240 KB Output is correct
43 Correct 372 ms 69660 KB Output is correct
44 Correct 406 ms 69980 KB Output is correct
45 Correct 392 ms 73812 KB Output is correct
46 Correct 459 ms 71672 KB Output is correct
47 Correct 390 ms 67024 KB Output is correct
48 Correct 434 ms 72592 KB Output is correct
49 Correct 521 ms 70848 KB Output is correct
50 Correct 377 ms 66820 KB Output is correct
51 Correct 0 ms 344 KB Output is correct
52 Correct 475 ms 74388 KB Output is correct
53 Correct 548 ms 69168 KB Output is correct
54 Correct 762 ms 77288 KB Output is correct
55 Correct 817 ms 92596 KB Output is correct
56 Correct 608 ms 78900 KB Output is correct
57 Correct 812 ms 100048 KB Output is correct
58 Correct 785 ms 89536 KB Output is correct
59 Correct 759 ms 89272 KB Output is correct
60 Correct 0 ms 344 KB Output is correct
61 Correct 774 ms 93072 KB Output is correct
62 Correct 675 ms 89732 KB Output is correct
63 Correct 650 ms 88272 KB Output is correct
64 Correct 641 ms 86948 KB Output is correct
65 Correct 593 ms 79824 KB Output is correct
66 Correct 609 ms 80300 KB Output is correct
67 Correct 968 ms 97660 KB Output is correct
68 Correct 3 ms 348 KB Output is correct
69 Execution timed out 1088 ms 11780 KB Time limit exceeded
70 Halted 0 ms 0 KB -