Submission #523848

# Submission time Handle Problem Language Result Execution time Memory
523848 2022-02-08T09:31:45 Z Bill_00 Bootfall (IZhO17_bootfall) C++14
44 / 100
1000 ms 964 KB
#include<bits/stdc++.h>
// #pragma GCC target("popcnt")
#define N 1000005
typedef long long ll;

using namespace std;

int a[N];
int n;
int sum;
bitset<250001> BS, ans, g;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	for(int i = 1; i <= 250000; i++){
		ans[i] = 1;
	}
	int n;
	cin >> n;

	BS[0] = 1;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		sum += a[i];
		BS = BS | (BS << a[i]);
	}

	if(sum % 2 == 0){
		int k = sum >> 1;
		if(BS[k] == 0){
			cout << 0;
			return 0;
		}
	}
	else{
		cout << 0;
		return 0;
	}

	for(int i = 1; i <= n; i++){
		BS.reset();
		g.reset();
		sum = 0;
		BS[0] = 1;
		for(int j = 1; j <= n; j++){
			if(i != j){
				BS = BS | (BS << a[j]);
				sum += a[j];
			}
		}
		for(int j = 0; j <= sum; j++){
			if(BS[j] == 1){
				g[abs(sum - 2 * j)] = 1;
			}
		}
		ans &= g;
	}
	vector<int> anss;
	for(int i = 1; i <= 250000; i++){
		if(ans[i] == 1){
			anss.push_back(i);
		}
	}
	cout << anss.size() << '\n';
	for(int value : anss) cout << value << ' ';



	
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 460 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 392 KB Output is correct
5 Correct 3 ms 460 KB Output is correct
6 Correct 3 ms 460 KB Output is correct
7 Correct 2 ms 460 KB Output is correct
8 Correct 3 ms 460 KB Output is correct
9 Correct 3 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 460 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 392 KB Output is correct
5 Correct 3 ms 460 KB Output is correct
6 Correct 3 ms 460 KB Output is correct
7 Correct 2 ms 460 KB Output is correct
8 Correct 3 ms 460 KB Output is correct
9 Correct 3 ms 460 KB Output is correct
10 Correct 9 ms 460 KB Output is correct
11 Correct 9 ms 460 KB Output is correct
12 Correct 11 ms 460 KB Output is correct
13 Correct 8 ms 472 KB Output is correct
14 Correct 8 ms 468 KB Output is correct
15 Correct 8 ms 460 KB Output is correct
16 Correct 9 ms 468 KB Output is correct
17 Correct 4 ms 460 KB Output is correct
18 Correct 8 ms 460 KB Output is correct
19 Correct 7 ms 460 KB Output is correct
20 Correct 9 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 460 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 392 KB Output is correct
5 Correct 3 ms 460 KB Output is correct
6 Correct 3 ms 460 KB Output is correct
7 Correct 2 ms 460 KB Output is correct
8 Correct 3 ms 460 KB Output is correct
9 Correct 3 ms 460 KB Output is correct
10 Correct 9 ms 460 KB Output is correct
11 Correct 9 ms 460 KB Output is correct
12 Correct 11 ms 460 KB Output is correct
13 Correct 8 ms 472 KB Output is correct
14 Correct 8 ms 468 KB Output is correct
15 Correct 8 ms 460 KB Output is correct
16 Correct 9 ms 468 KB Output is correct
17 Correct 4 ms 460 KB Output is correct
18 Correct 8 ms 460 KB Output is correct
19 Correct 7 ms 460 KB Output is correct
20 Correct 9 ms 460 KB Output is correct
21 Correct 39 ms 476 KB Output is correct
22 Correct 48 ms 464 KB Output is correct
23 Correct 23 ms 460 KB Output is correct
24 Correct 76 ms 460 KB Output is correct
25 Correct 76 ms 460 KB Output is correct
26 Correct 85 ms 460 KB Output is correct
27 Correct 85 ms 464 KB Output is correct
28 Correct 87 ms 460 KB Output is correct
29 Correct 86 ms 460 KB Output is correct
30 Correct 85 ms 460 KB Output is correct
31 Correct 85 ms 460 KB Output is correct
32 Correct 90 ms 460 KB Output is correct
33 Correct 86 ms 460 KB Output is correct
34 Correct 82 ms 460 KB Output is correct
35 Correct 83 ms 460 KB Output is correct
36 Correct 85 ms 464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 460 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 392 KB Output is correct
5 Correct 3 ms 460 KB Output is correct
6 Correct 3 ms 460 KB Output is correct
7 Correct 2 ms 460 KB Output is correct
8 Correct 3 ms 460 KB Output is correct
9 Correct 3 ms 460 KB Output is correct
10 Correct 9 ms 460 KB Output is correct
11 Correct 9 ms 460 KB Output is correct
12 Correct 11 ms 460 KB Output is correct
13 Correct 8 ms 472 KB Output is correct
14 Correct 8 ms 468 KB Output is correct
15 Correct 8 ms 460 KB Output is correct
16 Correct 9 ms 468 KB Output is correct
17 Correct 4 ms 460 KB Output is correct
18 Correct 8 ms 460 KB Output is correct
19 Correct 7 ms 460 KB Output is correct
20 Correct 9 ms 460 KB Output is correct
21 Correct 39 ms 476 KB Output is correct
22 Correct 48 ms 464 KB Output is correct
23 Correct 23 ms 460 KB Output is correct
24 Correct 76 ms 460 KB Output is correct
25 Correct 76 ms 460 KB Output is correct
26 Correct 85 ms 460 KB Output is correct
27 Correct 85 ms 464 KB Output is correct
28 Correct 87 ms 460 KB Output is correct
29 Correct 86 ms 460 KB Output is correct
30 Correct 85 ms 460 KB Output is correct
31 Correct 85 ms 460 KB Output is correct
32 Correct 90 ms 460 KB Output is correct
33 Correct 86 ms 460 KB Output is correct
34 Correct 82 ms 460 KB Output is correct
35 Correct 83 ms 460 KB Output is correct
36 Correct 85 ms 464 KB Output is correct
37 Correct 349 ms 576 KB Output is correct
38 Correct 336 ms 588 KB Output is correct
39 Correct 520 ms 464 KB Output is correct
40 Correct 624 ms 572 KB Output is correct
41 Correct 619 ms 460 KB Output is correct
42 Correct 533 ms 580 KB Output is correct
43 Correct 519 ms 840 KB Output is correct
44 Correct 533 ms 836 KB Output is correct
45 Correct 556 ms 964 KB Output is correct
46 Correct 602 ms 460 KB Output is correct
47 Correct 532 ms 580 KB Output is correct
48 Correct 550 ms 704 KB Output is correct
49 Correct 546 ms 464 KB Output is correct
50 Correct 536 ms 592 KB Output is correct
51 Correct 3 ms 332 KB Output is correct
52 Correct 636 ms 832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 460 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 392 KB Output is correct
5 Correct 3 ms 460 KB Output is correct
6 Correct 3 ms 460 KB Output is correct
7 Correct 2 ms 460 KB Output is correct
8 Correct 3 ms 460 KB Output is correct
9 Correct 3 ms 460 KB Output is correct
10 Correct 9 ms 460 KB Output is correct
11 Correct 9 ms 460 KB Output is correct
12 Correct 11 ms 460 KB Output is correct
13 Correct 8 ms 472 KB Output is correct
14 Correct 8 ms 468 KB Output is correct
15 Correct 8 ms 460 KB Output is correct
16 Correct 9 ms 468 KB Output is correct
17 Correct 4 ms 460 KB Output is correct
18 Correct 8 ms 460 KB Output is correct
19 Correct 7 ms 460 KB Output is correct
20 Correct 9 ms 460 KB Output is correct
21 Correct 39 ms 476 KB Output is correct
22 Correct 48 ms 464 KB Output is correct
23 Correct 23 ms 460 KB Output is correct
24 Correct 76 ms 460 KB Output is correct
25 Correct 76 ms 460 KB Output is correct
26 Correct 85 ms 460 KB Output is correct
27 Correct 85 ms 464 KB Output is correct
28 Correct 87 ms 460 KB Output is correct
29 Correct 86 ms 460 KB Output is correct
30 Correct 85 ms 460 KB Output is correct
31 Correct 85 ms 460 KB Output is correct
32 Correct 90 ms 460 KB Output is correct
33 Correct 86 ms 460 KB Output is correct
34 Correct 82 ms 460 KB Output is correct
35 Correct 83 ms 460 KB Output is correct
36 Correct 85 ms 464 KB Output is correct
37 Correct 349 ms 576 KB Output is correct
38 Correct 336 ms 588 KB Output is correct
39 Correct 520 ms 464 KB Output is correct
40 Correct 624 ms 572 KB Output is correct
41 Correct 619 ms 460 KB Output is correct
42 Correct 533 ms 580 KB Output is correct
43 Correct 519 ms 840 KB Output is correct
44 Correct 533 ms 836 KB Output is correct
45 Correct 556 ms 964 KB Output is correct
46 Correct 602 ms 460 KB Output is correct
47 Correct 532 ms 580 KB Output is correct
48 Correct 550 ms 704 KB Output is correct
49 Correct 546 ms 464 KB Output is correct
50 Correct 536 ms 592 KB Output is correct
51 Correct 3 ms 332 KB Output is correct
52 Correct 636 ms 832 KB Output is correct
53 Correct 774 ms 704 KB Output is correct
54 Execution timed out 1051 ms 828 KB Time limit exceeded
55 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 460 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 392 KB Output is correct
5 Correct 3 ms 460 KB Output is correct
6 Correct 3 ms 460 KB Output is correct
7 Correct 2 ms 460 KB Output is correct
8 Correct 3 ms 460 KB Output is correct
9 Correct 3 ms 460 KB Output is correct
10 Correct 9 ms 460 KB Output is correct
11 Correct 9 ms 460 KB Output is correct
12 Correct 11 ms 460 KB Output is correct
13 Correct 8 ms 472 KB Output is correct
14 Correct 8 ms 468 KB Output is correct
15 Correct 8 ms 460 KB Output is correct
16 Correct 9 ms 468 KB Output is correct
17 Correct 4 ms 460 KB Output is correct
18 Correct 8 ms 460 KB Output is correct
19 Correct 7 ms 460 KB Output is correct
20 Correct 9 ms 460 KB Output is correct
21 Correct 39 ms 476 KB Output is correct
22 Correct 48 ms 464 KB Output is correct
23 Correct 23 ms 460 KB Output is correct
24 Correct 76 ms 460 KB Output is correct
25 Correct 76 ms 460 KB Output is correct
26 Correct 85 ms 460 KB Output is correct
27 Correct 85 ms 464 KB Output is correct
28 Correct 87 ms 460 KB Output is correct
29 Correct 86 ms 460 KB Output is correct
30 Correct 85 ms 460 KB Output is correct
31 Correct 85 ms 460 KB Output is correct
32 Correct 90 ms 460 KB Output is correct
33 Correct 86 ms 460 KB Output is correct
34 Correct 82 ms 460 KB Output is correct
35 Correct 83 ms 460 KB Output is correct
36 Correct 85 ms 464 KB Output is correct
37 Correct 349 ms 576 KB Output is correct
38 Correct 336 ms 588 KB Output is correct
39 Correct 520 ms 464 KB Output is correct
40 Correct 624 ms 572 KB Output is correct
41 Correct 619 ms 460 KB Output is correct
42 Correct 533 ms 580 KB Output is correct
43 Correct 519 ms 840 KB Output is correct
44 Correct 533 ms 836 KB Output is correct
45 Correct 556 ms 964 KB Output is correct
46 Correct 602 ms 460 KB Output is correct
47 Correct 532 ms 580 KB Output is correct
48 Correct 550 ms 704 KB Output is correct
49 Correct 546 ms 464 KB Output is correct
50 Correct 536 ms 592 KB Output is correct
51 Correct 3 ms 332 KB Output is correct
52 Correct 636 ms 832 KB Output is correct
53 Correct 774 ms 704 KB Output is correct
54 Execution timed out 1051 ms 828 KB Time limit exceeded
55 Halted 0 ms 0 KB -