Submission #1107916

# Submission time Handle Problem Language Result Execution time Memory
1107916 2024-11-02T10:35:56 Z alex_2008 Bootfall (IZhO17_bootfall) C++14
65 / 100
1000 ms 4624 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define ff first
#define ss second
typedef long long ll;
using namespace std;
const int P1 = 727196341;
const int P2 = 271915031;
const int N = 500 + 10;
int a[N];
int dp1[N * N];
int dp2[N * N];
int cnt[N * N];
void add(int x) {
	for (int i = N * N - 1; i >= x; i--) {
		dp1[i] = (dp1[i - x] + dp1[i]) % P1;
		dp2[i] = (dp2[i - x] + dp2[i]) % P2;
	}
}
void sub(int x) {
	for (int i = x; i < N * N; i++) {
		dp1[i] = (dp1[i] - dp1[i - x] + P1) % P1;
		dp2[i] = (dp2[i] - dp2[i - x] + P2) % P2;
	}
}
int main() {
	int n;
	cin >> n;
	int sm = 0;
	dp1[0] = 1;
	dp2[0] = 1;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		add(a[i]);
		sm += a[i];
	}
	if (sm % 2 != 0) {
		cout << 0 << "\n";
		return 0;
	}
	if (dp1[sm / 2] == 0 && dp2[sm / 2] == 0) {
		cout << 0 << "\n";
		return 0;
	}
	for (int i = 1; i <= n; i++) {
		sub(a[i]);
		sm -= a[i];
		for (int i = 0; 2 * i < sm; i++) {
			if ((dp1[i] != 0 || dp2[i] != 0)) {
				cnt[sm - 2 * i]++;
			}
		}
		add(a[i]);
		sm += a[i];
	}
	vector <int> ans;
	for (int i = 1; i < N * N; i++) {
		if (cnt[i] == n) ans.push_back(i);
	}
	cout << (int)ans.size() << "\n";
	for (auto it : ans) {
		cout << it << " ";
	}
	cout << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 12 ms 3152 KB Output is correct
2 Correct 18 ms 3152 KB Output is correct
3 Correct 3 ms 3320 KB Output is correct
4 Correct 10 ms 3408 KB Output is correct
5 Correct 24 ms 3152 KB Output is correct
6 Correct 17 ms 3152 KB Output is correct
7 Correct 13 ms 3152 KB Output is correct
8 Correct 25 ms 3320 KB Output is correct
9 Correct 20 ms 3152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 3152 KB Output is correct
2 Correct 18 ms 3152 KB Output is correct
3 Correct 3 ms 3320 KB Output is correct
4 Correct 10 ms 3408 KB Output is correct
5 Correct 24 ms 3152 KB Output is correct
6 Correct 17 ms 3152 KB Output is correct
7 Correct 13 ms 3152 KB Output is correct
8 Correct 25 ms 3320 KB Output is correct
9 Correct 20 ms 3152 KB Output is correct
10 Correct 58 ms 3152 KB Output is correct
11 Correct 69 ms 3152 KB Output is correct
12 Correct 64 ms 3152 KB Output is correct
13 Correct 54 ms 3308 KB Output is correct
14 Correct 68 ms 3152 KB Output is correct
15 Correct 68 ms 3152 KB Output is correct
16 Correct 75 ms 3152 KB Output is correct
17 Correct 39 ms 3152 KB Output is correct
18 Correct 50 ms 3304 KB Output is correct
19 Correct 59 ms 3152 KB Output is correct
20 Correct 57 ms 3152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 3152 KB Output is correct
2 Correct 18 ms 3152 KB Output is correct
3 Correct 3 ms 3320 KB Output is correct
4 Correct 10 ms 3408 KB Output is correct
5 Correct 24 ms 3152 KB Output is correct
6 Correct 17 ms 3152 KB Output is correct
7 Correct 13 ms 3152 KB Output is correct
8 Correct 25 ms 3320 KB Output is correct
9 Correct 20 ms 3152 KB Output is correct
10 Correct 58 ms 3152 KB Output is correct
11 Correct 69 ms 3152 KB Output is correct
12 Correct 64 ms 3152 KB Output is correct
13 Correct 54 ms 3308 KB Output is correct
14 Correct 68 ms 3152 KB Output is correct
15 Correct 68 ms 3152 KB Output is correct
16 Correct 75 ms 3152 KB Output is correct
17 Correct 39 ms 3152 KB Output is correct
18 Correct 50 ms 3304 KB Output is correct
19 Correct 59 ms 3152 KB Output is correct
20 Correct 57 ms 3152 KB Output is correct
21 Correct 123 ms 3320 KB Output is correct
22 Correct 156 ms 3152 KB Output is correct
23 Correct 106 ms 3152 KB Output is correct
24 Correct 190 ms 3152 KB Output is correct
25 Correct 172 ms 3152 KB Output is correct
26 Correct 184 ms 3304 KB Output is correct
27 Correct 206 ms 3336 KB Output is correct
28 Correct 193 ms 3340 KB Output is correct
29 Correct 183 ms 3316 KB Output is correct
30 Correct 197 ms 3152 KB Output is correct
31 Correct 184 ms 3152 KB Output is correct
32 Correct 189 ms 3152 KB Output is correct
33 Correct 200 ms 3324 KB Output is correct
34 Correct 193 ms 3152 KB Output is correct
35 Correct 184 ms 3320 KB Output is correct
36 Correct 203 ms 3152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 3152 KB Output is correct
2 Correct 18 ms 3152 KB Output is correct
3 Correct 3 ms 3320 KB Output is correct
4 Correct 10 ms 3408 KB Output is correct
5 Correct 24 ms 3152 KB Output is correct
6 Correct 17 ms 3152 KB Output is correct
7 Correct 13 ms 3152 KB Output is correct
8 Correct 25 ms 3320 KB Output is correct
9 Correct 20 ms 3152 KB Output is correct
10 Correct 58 ms 3152 KB Output is correct
11 Correct 69 ms 3152 KB Output is correct
12 Correct 64 ms 3152 KB Output is correct
13 Correct 54 ms 3308 KB Output is correct
14 Correct 68 ms 3152 KB Output is correct
15 Correct 68 ms 3152 KB Output is correct
16 Correct 75 ms 3152 KB Output is correct
17 Correct 39 ms 3152 KB Output is correct
18 Correct 50 ms 3304 KB Output is correct
19 Correct 59 ms 3152 KB Output is correct
20 Correct 57 ms 3152 KB Output is correct
21 Correct 123 ms 3320 KB Output is correct
22 Correct 156 ms 3152 KB Output is correct
23 Correct 106 ms 3152 KB Output is correct
24 Correct 190 ms 3152 KB Output is correct
25 Correct 172 ms 3152 KB Output is correct
26 Correct 184 ms 3304 KB Output is correct
27 Correct 206 ms 3336 KB Output is correct
28 Correct 193 ms 3340 KB Output is correct
29 Correct 183 ms 3316 KB Output is correct
30 Correct 197 ms 3152 KB Output is correct
31 Correct 184 ms 3152 KB Output is correct
32 Correct 189 ms 3152 KB Output is correct
33 Correct 200 ms 3324 KB Output is correct
34 Correct 193 ms 3152 KB Output is correct
35 Correct 184 ms 3320 KB Output is correct
36 Correct 203 ms 3152 KB Output is correct
37 Correct 402 ms 3312 KB Output is correct
38 Correct 366 ms 3320 KB Output is correct
39 Correct 470 ms 3400 KB Output is correct
40 Correct 510 ms 3568 KB Output is correct
41 Correct 493 ms 3488 KB Output is correct
42 Correct 473 ms 3656 KB Output is correct
43 Correct 456 ms 3656 KB Output is correct
44 Correct 469 ms 3656 KB Output is correct
45 Correct 485 ms 3740 KB Output is correct
46 Correct 565 ms 3316 KB Output is correct
47 Correct 467 ms 3572 KB Output is correct
48 Correct 475 ms 3656 KB Output is correct
49 Correct 466 ms 3560 KB Output is correct
50 Correct 474 ms 3436 KB Output is correct
51 Correct 146 ms 3152 KB Output is correct
52 Correct 549 ms 3820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 3152 KB Output is correct
2 Correct 18 ms 3152 KB Output is correct
3 Correct 3 ms 3320 KB Output is correct
4 Correct 10 ms 3408 KB Output is correct
5 Correct 24 ms 3152 KB Output is correct
6 Correct 17 ms 3152 KB Output is correct
7 Correct 13 ms 3152 KB Output is correct
8 Correct 25 ms 3320 KB Output is correct
9 Correct 20 ms 3152 KB Output is correct
10 Correct 58 ms 3152 KB Output is correct
11 Correct 69 ms 3152 KB Output is correct
12 Correct 64 ms 3152 KB Output is correct
13 Correct 54 ms 3308 KB Output is correct
14 Correct 68 ms 3152 KB Output is correct
15 Correct 68 ms 3152 KB Output is correct
16 Correct 75 ms 3152 KB Output is correct
17 Correct 39 ms 3152 KB Output is correct
18 Correct 50 ms 3304 KB Output is correct
19 Correct 59 ms 3152 KB Output is correct
20 Correct 57 ms 3152 KB Output is correct
21 Correct 123 ms 3320 KB Output is correct
22 Correct 156 ms 3152 KB Output is correct
23 Correct 106 ms 3152 KB Output is correct
24 Correct 190 ms 3152 KB Output is correct
25 Correct 172 ms 3152 KB Output is correct
26 Correct 184 ms 3304 KB Output is correct
27 Correct 206 ms 3336 KB Output is correct
28 Correct 193 ms 3340 KB Output is correct
29 Correct 183 ms 3316 KB Output is correct
30 Correct 197 ms 3152 KB Output is correct
31 Correct 184 ms 3152 KB Output is correct
32 Correct 189 ms 3152 KB Output is correct
33 Correct 200 ms 3324 KB Output is correct
34 Correct 193 ms 3152 KB Output is correct
35 Correct 184 ms 3320 KB Output is correct
36 Correct 203 ms 3152 KB Output is correct
37 Correct 402 ms 3312 KB Output is correct
38 Correct 366 ms 3320 KB Output is correct
39 Correct 470 ms 3400 KB Output is correct
40 Correct 510 ms 3568 KB Output is correct
41 Correct 493 ms 3488 KB Output is correct
42 Correct 473 ms 3656 KB Output is correct
43 Correct 456 ms 3656 KB Output is correct
44 Correct 469 ms 3656 KB Output is correct
45 Correct 485 ms 3740 KB Output is correct
46 Correct 565 ms 3316 KB Output is correct
47 Correct 467 ms 3572 KB Output is correct
48 Correct 475 ms 3656 KB Output is correct
49 Correct 466 ms 3560 KB Output is correct
50 Correct 474 ms 3436 KB Output is correct
51 Correct 146 ms 3152 KB Output is correct
52 Correct 549 ms 3820 KB Output is correct
53 Correct 561 ms 3656 KB Output is correct
54 Correct 652 ms 3820 KB Output is correct
55 Correct 685 ms 4040 KB Output is correct
56 Correct 569 ms 3736 KB Output is correct
57 Correct 676 ms 4120 KB Output is correct
58 Correct 669 ms 3828 KB Output is correct
59 Correct 663 ms 3860 KB Output is correct
60 Correct 196 ms 3152 KB Output is correct
61 Correct 658 ms 3944 KB Output is correct
62 Correct 595 ms 4036 KB Output is correct
63 Correct 607 ms 4036 KB Output is correct
64 Correct 591 ms 3864 KB Output is correct
65 Correct 589 ms 3316 KB Output is correct
66 Correct 574 ms 3484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 3152 KB Output is correct
2 Correct 18 ms 3152 KB Output is correct
3 Correct 3 ms 3320 KB Output is correct
4 Correct 10 ms 3408 KB Output is correct
5 Correct 24 ms 3152 KB Output is correct
6 Correct 17 ms 3152 KB Output is correct
7 Correct 13 ms 3152 KB Output is correct
8 Correct 25 ms 3320 KB Output is correct
9 Correct 20 ms 3152 KB Output is correct
10 Correct 58 ms 3152 KB Output is correct
11 Correct 69 ms 3152 KB Output is correct
12 Correct 64 ms 3152 KB Output is correct
13 Correct 54 ms 3308 KB Output is correct
14 Correct 68 ms 3152 KB Output is correct
15 Correct 68 ms 3152 KB Output is correct
16 Correct 75 ms 3152 KB Output is correct
17 Correct 39 ms 3152 KB Output is correct
18 Correct 50 ms 3304 KB Output is correct
19 Correct 59 ms 3152 KB Output is correct
20 Correct 57 ms 3152 KB Output is correct
21 Correct 123 ms 3320 KB Output is correct
22 Correct 156 ms 3152 KB Output is correct
23 Correct 106 ms 3152 KB Output is correct
24 Correct 190 ms 3152 KB Output is correct
25 Correct 172 ms 3152 KB Output is correct
26 Correct 184 ms 3304 KB Output is correct
27 Correct 206 ms 3336 KB Output is correct
28 Correct 193 ms 3340 KB Output is correct
29 Correct 183 ms 3316 KB Output is correct
30 Correct 197 ms 3152 KB Output is correct
31 Correct 184 ms 3152 KB Output is correct
32 Correct 189 ms 3152 KB Output is correct
33 Correct 200 ms 3324 KB Output is correct
34 Correct 193 ms 3152 KB Output is correct
35 Correct 184 ms 3320 KB Output is correct
36 Correct 203 ms 3152 KB Output is correct
37 Correct 402 ms 3312 KB Output is correct
38 Correct 366 ms 3320 KB Output is correct
39 Correct 470 ms 3400 KB Output is correct
40 Correct 510 ms 3568 KB Output is correct
41 Correct 493 ms 3488 KB Output is correct
42 Correct 473 ms 3656 KB Output is correct
43 Correct 456 ms 3656 KB Output is correct
44 Correct 469 ms 3656 KB Output is correct
45 Correct 485 ms 3740 KB Output is correct
46 Correct 565 ms 3316 KB Output is correct
47 Correct 467 ms 3572 KB Output is correct
48 Correct 475 ms 3656 KB Output is correct
49 Correct 466 ms 3560 KB Output is correct
50 Correct 474 ms 3436 KB Output is correct
51 Correct 146 ms 3152 KB Output is correct
52 Correct 549 ms 3820 KB Output is correct
53 Correct 561 ms 3656 KB Output is correct
54 Correct 652 ms 3820 KB Output is correct
55 Correct 685 ms 4040 KB Output is correct
56 Correct 569 ms 3736 KB Output is correct
57 Correct 676 ms 4120 KB Output is correct
58 Correct 669 ms 3828 KB Output is correct
59 Correct 663 ms 3860 KB Output is correct
60 Correct 196 ms 3152 KB Output is correct
61 Correct 658 ms 3944 KB Output is correct
62 Correct 595 ms 4036 KB Output is correct
63 Correct 607 ms 4036 KB Output is correct
64 Correct 591 ms 3864 KB Output is correct
65 Correct 589 ms 3316 KB Output is correct
66 Correct 574 ms 3484 KB Output is correct
67 Correct 759 ms 3864 KB Output is correct
68 Correct 278 ms 3152 KB Output is correct
69 Correct 952 ms 4624 KB Output is correct
70 Correct 951 ms 4036 KB Output is correct
71 Execution timed out 1002 ms 4208 KB Time limit exceeded
72 Halted 0 ms 0 KB -