답안 #523842

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
523842 2022-02-08T09:22:18 Z Bill_00 Bootfall (IZhO17_bootfall) C++14
28 / 100
1000 ms 788 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<500000> 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 << ' ';



	
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 588 KB Output is correct
2 Correct 2 ms 588 KB Output is correct
3 Correct 2 ms 460 KB Output is correct
4 Correct 2 ms 588 KB Output is correct
5 Correct 5 ms 588 KB Output is correct
6 Correct 3 ms 588 KB Output is correct
7 Correct 3 ms 588 KB Output is correct
8 Correct 4 ms 588 KB Output is correct
9 Correct 5 ms 588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 588 KB Output is correct
2 Correct 2 ms 588 KB Output is correct
3 Correct 2 ms 460 KB Output is correct
4 Correct 2 ms 588 KB Output is correct
5 Correct 5 ms 588 KB Output is correct
6 Correct 3 ms 588 KB Output is correct
7 Correct 3 ms 588 KB Output is correct
8 Correct 4 ms 588 KB Output is correct
9 Correct 5 ms 588 KB Output is correct
10 Correct 20 ms 628 KB Output is correct
11 Correct 18 ms 588 KB Output is correct
12 Correct 23 ms 588 KB Output is correct
13 Correct 13 ms 628 KB Output is correct
14 Correct 16 ms 628 KB Output is correct
15 Correct 21 ms 624 KB Output is correct
16 Correct 18 ms 588 KB Output is correct
17 Correct 7 ms 620 KB Output is correct
18 Correct 11 ms 624 KB Output is correct
19 Correct 14 ms 624 KB Output is correct
20 Correct 25 ms 624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 588 KB Output is correct
2 Correct 2 ms 588 KB Output is correct
3 Correct 2 ms 460 KB Output is correct
4 Correct 2 ms 588 KB Output is correct
5 Correct 5 ms 588 KB Output is correct
6 Correct 3 ms 588 KB Output is correct
7 Correct 3 ms 588 KB Output is correct
8 Correct 4 ms 588 KB Output is correct
9 Correct 5 ms 588 KB Output is correct
10 Correct 20 ms 628 KB Output is correct
11 Correct 18 ms 588 KB Output is correct
12 Correct 23 ms 588 KB Output is correct
13 Correct 13 ms 628 KB Output is correct
14 Correct 16 ms 628 KB Output is correct
15 Correct 21 ms 624 KB Output is correct
16 Correct 18 ms 588 KB Output is correct
17 Correct 7 ms 620 KB Output is correct
18 Correct 11 ms 624 KB Output is correct
19 Correct 14 ms 624 KB Output is correct
20 Correct 25 ms 624 KB Output is correct
21 Correct 93 ms 604 KB Output is correct
22 Correct 106 ms 608 KB Output is correct
23 Correct 47 ms 620 KB Output is correct
24 Correct 164 ms 604 KB Output is correct
25 Correct 162 ms 612 KB Output is correct
26 Correct 189 ms 608 KB Output is correct
27 Correct 182 ms 616 KB Output is correct
28 Correct 180 ms 616 KB Output is correct
29 Correct 191 ms 604 KB Output is correct
30 Correct 182 ms 600 KB Output is correct
31 Correct 177 ms 604 KB Output is correct
32 Correct 180 ms 616 KB Output is correct
33 Correct 181 ms 604 KB Output is correct
34 Correct 178 ms 608 KB Output is correct
35 Correct 178 ms 604 KB Output is correct
36 Correct 223 ms 612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 588 KB Output is correct
2 Correct 2 ms 588 KB Output is correct
3 Correct 2 ms 460 KB Output is correct
4 Correct 2 ms 588 KB Output is correct
5 Correct 5 ms 588 KB Output is correct
6 Correct 3 ms 588 KB Output is correct
7 Correct 3 ms 588 KB Output is correct
8 Correct 4 ms 588 KB Output is correct
9 Correct 5 ms 588 KB Output is correct
10 Correct 20 ms 628 KB Output is correct
11 Correct 18 ms 588 KB Output is correct
12 Correct 23 ms 588 KB Output is correct
13 Correct 13 ms 628 KB Output is correct
14 Correct 16 ms 628 KB Output is correct
15 Correct 21 ms 624 KB Output is correct
16 Correct 18 ms 588 KB Output is correct
17 Correct 7 ms 620 KB Output is correct
18 Correct 11 ms 624 KB Output is correct
19 Correct 14 ms 624 KB Output is correct
20 Correct 25 ms 624 KB Output is correct
21 Correct 93 ms 604 KB Output is correct
22 Correct 106 ms 608 KB Output is correct
23 Correct 47 ms 620 KB Output is correct
24 Correct 164 ms 604 KB Output is correct
25 Correct 162 ms 612 KB Output is correct
26 Correct 189 ms 608 KB Output is correct
27 Correct 182 ms 616 KB Output is correct
28 Correct 180 ms 616 KB Output is correct
29 Correct 191 ms 604 KB Output is correct
30 Correct 182 ms 600 KB Output is correct
31 Correct 177 ms 604 KB Output is correct
32 Correct 180 ms 616 KB Output is correct
33 Correct 181 ms 604 KB Output is correct
34 Correct 178 ms 608 KB Output is correct
35 Correct 178 ms 604 KB Output is correct
36 Correct 223 ms 612 KB Output is correct
37 Correct 731 ms 736 KB Output is correct
38 Correct 702 ms 788 KB Output is correct
39 Execution timed out 1089 ms 588 KB Time limit exceeded
40 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 588 KB Output is correct
2 Correct 2 ms 588 KB Output is correct
3 Correct 2 ms 460 KB Output is correct
4 Correct 2 ms 588 KB Output is correct
5 Correct 5 ms 588 KB Output is correct
6 Correct 3 ms 588 KB Output is correct
7 Correct 3 ms 588 KB Output is correct
8 Correct 4 ms 588 KB Output is correct
9 Correct 5 ms 588 KB Output is correct
10 Correct 20 ms 628 KB Output is correct
11 Correct 18 ms 588 KB Output is correct
12 Correct 23 ms 588 KB Output is correct
13 Correct 13 ms 628 KB Output is correct
14 Correct 16 ms 628 KB Output is correct
15 Correct 21 ms 624 KB Output is correct
16 Correct 18 ms 588 KB Output is correct
17 Correct 7 ms 620 KB Output is correct
18 Correct 11 ms 624 KB Output is correct
19 Correct 14 ms 624 KB Output is correct
20 Correct 25 ms 624 KB Output is correct
21 Correct 93 ms 604 KB Output is correct
22 Correct 106 ms 608 KB Output is correct
23 Correct 47 ms 620 KB Output is correct
24 Correct 164 ms 604 KB Output is correct
25 Correct 162 ms 612 KB Output is correct
26 Correct 189 ms 608 KB Output is correct
27 Correct 182 ms 616 KB Output is correct
28 Correct 180 ms 616 KB Output is correct
29 Correct 191 ms 604 KB Output is correct
30 Correct 182 ms 600 KB Output is correct
31 Correct 177 ms 604 KB Output is correct
32 Correct 180 ms 616 KB Output is correct
33 Correct 181 ms 604 KB Output is correct
34 Correct 178 ms 608 KB Output is correct
35 Correct 178 ms 604 KB Output is correct
36 Correct 223 ms 612 KB Output is correct
37 Correct 731 ms 736 KB Output is correct
38 Correct 702 ms 788 KB Output is correct
39 Execution timed out 1089 ms 588 KB Time limit exceeded
40 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 588 KB Output is correct
2 Correct 2 ms 588 KB Output is correct
3 Correct 2 ms 460 KB Output is correct
4 Correct 2 ms 588 KB Output is correct
5 Correct 5 ms 588 KB Output is correct
6 Correct 3 ms 588 KB Output is correct
7 Correct 3 ms 588 KB Output is correct
8 Correct 4 ms 588 KB Output is correct
9 Correct 5 ms 588 KB Output is correct
10 Correct 20 ms 628 KB Output is correct
11 Correct 18 ms 588 KB Output is correct
12 Correct 23 ms 588 KB Output is correct
13 Correct 13 ms 628 KB Output is correct
14 Correct 16 ms 628 KB Output is correct
15 Correct 21 ms 624 KB Output is correct
16 Correct 18 ms 588 KB Output is correct
17 Correct 7 ms 620 KB Output is correct
18 Correct 11 ms 624 KB Output is correct
19 Correct 14 ms 624 KB Output is correct
20 Correct 25 ms 624 KB Output is correct
21 Correct 93 ms 604 KB Output is correct
22 Correct 106 ms 608 KB Output is correct
23 Correct 47 ms 620 KB Output is correct
24 Correct 164 ms 604 KB Output is correct
25 Correct 162 ms 612 KB Output is correct
26 Correct 189 ms 608 KB Output is correct
27 Correct 182 ms 616 KB Output is correct
28 Correct 180 ms 616 KB Output is correct
29 Correct 191 ms 604 KB Output is correct
30 Correct 182 ms 600 KB Output is correct
31 Correct 177 ms 604 KB Output is correct
32 Correct 180 ms 616 KB Output is correct
33 Correct 181 ms 604 KB Output is correct
34 Correct 178 ms 608 KB Output is correct
35 Correct 178 ms 604 KB Output is correct
36 Correct 223 ms 612 KB Output is correct
37 Correct 731 ms 736 KB Output is correct
38 Correct 702 ms 788 KB Output is correct
39 Execution timed out 1089 ms 588 KB Time limit exceeded
40 Halted 0 ms 0 KB -