답안 #475352

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
475352 2021-09-22T05:37:51 Z ismoilov Bootfall (IZhO17_bootfall) C++14
100 / 100
279 ms 49124 KB
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const int maxx = 505;

vector <int> ach[maxx*4];
bitset<maxx*maxx> pos[maxx*4];

//node tr[maxx*4];

bitset <maxx*maxx> out[maxx];
void update(int l, int r, int tl, int tr, int id, int val){
//	cout << tl << " " << tr << " " << val << " done\n";
	if(l > tr || r < tl)
		return;
	if(l >= tl && r <= tr){
		ach[id].push_back(val);
	//	cout << "added " << l << " " << r  << " " << id << "\n";
		return;
	}
	int m = (l + r) / 2;
	update(l, m, tl, tr, id+id, val);
	update(m+1, r, tl ,tr, id+id+1, val);
//	cout << "finally\n";
}

void build(int l, int r, int id){
	pos[id][0] = 1;
	for(auto it : ach[id])
		pos[id] |= (pos[id] << it);
	
	if(l == r){
		out[l] = pos[id];
		return;
	}
	
	int m = (l + r) / 2;
	pos[id+id] = pos[id];
	pos[id+id+1] = pos[id];
	build(l, m, id+id);
	build(m+1, r, id+id+1);
}

void S()
{
	int n;
	cin >> n;
	vector <int> a(n+1);
	int s = 0;
	for(int i = 1; i <= n; i ++){
		cin >> a[i];
		s += a[i];
	}
	if(s % 2 == 1){
		cout << 0;
		return;
	}
	
	for(int i = 1; i <= n; i ++){
		update(1, n+1, 1, i-1, 1, a[i]);
		update(1, n+1, i+1, n+1, 1, a[i]);
	}
//	cout << s;/*
	build(1, n+1, 1);
	
	if(out[n+1][s/2] == 0){
		cout << 0;
		return;
	}
	
	vector <int> ans;
	for(int can = 1; can <= s; can ++){
		bool ok = 1;
		for(int i = 1; i <= n; i ++){
			int s1 = s - a[i] + can;
			if(s1 % 2 == 1 || out[i][s1/2] == 0){
				ok = 0;
				break;
			}
		}
		if(ok)
			ans.push_back(can);
	}
	cout << ans.size() << "\n";
	for(auto it : ans)
		cout << it << " ";
}

int main()
{
	IOS;
	/*int t;
	cin >> t;
	while(t --)*/
		S();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 2 ms 1228 KB Output is correct
3 Correct 1 ms 844 KB Output is correct
4 Correct 1 ms 972 KB Output is correct
5 Correct 2 ms 1740 KB Output is correct
6 Correct 1 ms 1420 KB Output is correct
7 Correct 2 ms 1100 KB Output is correct
8 Correct 2 ms 1868 KB Output is correct
9 Correct 1 ms 1652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 2 ms 1228 KB Output is correct
3 Correct 1 ms 844 KB Output is correct
4 Correct 1 ms 972 KB Output is correct
5 Correct 2 ms 1740 KB Output is correct
6 Correct 1 ms 1420 KB Output is correct
7 Correct 2 ms 1100 KB Output is correct
8 Correct 2 ms 1868 KB Output is correct
9 Correct 1 ms 1652 KB Output is correct
10 Correct 4 ms 3532 KB Output is correct
11 Correct 4 ms 3532 KB Output is correct
12 Correct 4 ms 3572 KB Output is correct
13 Correct 3 ms 3148 KB Output is correct
14 Correct 4 ms 3404 KB Output is correct
15 Correct 3 ms 3404 KB Output is correct
16 Correct 4 ms 3576 KB Output is correct
17 Correct 2 ms 2416 KB Output is correct
18 Correct 3 ms 3020 KB Output is correct
19 Correct 3 ms 3148 KB Output is correct
20 Correct 4 ms 3524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 2 ms 1228 KB Output is correct
3 Correct 1 ms 844 KB Output is correct
4 Correct 1 ms 972 KB Output is correct
5 Correct 2 ms 1740 KB Output is correct
6 Correct 1 ms 1420 KB Output is correct
7 Correct 2 ms 1100 KB Output is correct
8 Correct 2 ms 1868 KB Output is correct
9 Correct 1 ms 1652 KB Output is correct
10 Correct 4 ms 3532 KB Output is correct
11 Correct 4 ms 3532 KB Output is correct
12 Correct 4 ms 3572 KB Output is correct
13 Correct 3 ms 3148 KB Output is correct
14 Correct 4 ms 3404 KB Output is correct
15 Correct 3 ms 3404 KB Output is correct
16 Correct 4 ms 3576 KB Output is correct
17 Correct 2 ms 2416 KB Output is correct
18 Correct 3 ms 3020 KB Output is correct
19 Correct 3 ms 3148 KB Output is correct
20 Correct 4 ms 3524 KB Output is correct
21 Correct 8 ms 6860 KB Output is correct
22 Correct 9 ms 7884 KB Output is correct
23 Correct 6 ms 5580 KB Output is correct
24 Correct 12 ms 9804 KB Output is correct
25 Correct 13 ms 9804 KB Output is correct
26 Correct 13 ms 10316 KB Output is correct
27 Correct 12 ms 10316 KB Output is correct
28 Correct 12 ms 10316 KB Output is correct
29 Correct 12 ms 10316 KB Output is correct
30 Correct 12 ms 10316 KB Output is correct
31 Correct 13 ms 10316 KB Output is correct
32 Correct 13 ms 10436 KB Output is correct
33 Correct 14 ms 10364 KB Output is correct
34 Correct 14 ms 10336 KB Output is correct
35 Correct 14 ms 10288 KB Output is correct
36 Correct 12 ms 10316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 2 ms 1228 KB Output is correct
3 Correct 1 ms 844 KB Output is correct
4 Correct 1 ms 972 KB Output is correct
5 Correct 2 ms 1740 KB Output is correct
6 Correct 1 ms 1420 KB Output is correct
7 Correct 2 ms 1100 KB Output is correct
8 Correct 2 ms 1868 KB Output is correct
9 Correct 1 ms 1652 KB Output is correct
10 Correct 4 ms 3532 KB Output is correct
11 Correct 4 ms 3532 KB Output is correct
12 Correct 4 ms 3572 KB Output is correct
13 Correct 3 ms 3148 KB Output is correct
14 Correct 4 ms 3404 KB Output is correct
15 Correct 3 ms 3404 KB Output is correct
16 Correct 4 ms 3576 KB Output is correct
17 Correct 2 ms 2416 KB Output is correct
18 Correct 3 ms 3020 KB Output is correct
19 Correct 3 ms 3148 KB Output is correct
20 Correct 4 ms 3524 KB Output is correct
21 Correct 8 ms 6860 KB Output is correct
22 Correct 9 ms 7884 KB Output is correct
23 Correct 6 ms 5580 KB Output is correct
24 Correct 12 ms 9804 KB Output is correct
25 Correct 13 ms 9804 KB Output is correct
26 Correct 13 ms 10316 KB Output is correct
27 Correct 12 ms 10316 KB Output is correct
28 Correct 12 ms 10316 KB Output is correct
29 Correct 12 ms 10316 KB Output is correct
30 Correct 12 ms 10316 KB Output is correct
31 Correct 13 ms 10316 KB Output is correct
32 Correct 13 ms 10436 KB Output is correct
33 Correct 14 ms 10364 KB Output is correct
34 Correct 14 ms 10336 KB Output is correct
35 Correct 14 ms 10288 KB Output is correct
36 Correct 12 ms 10316 KB Output is correct
37 Correct 31 ms 19976 KB Output is correct
38 Correct 30 ms 20020 KB Output is correct
39 Correct 31 ms 24172 KB Output is correct
40 Correct 49 ms 26564 KB Output is correct
41 Correct 33 ms 26328 KB Output is correct
42 Correct 46 ms 24504 KB Output is correct
43 Correct 52 ms 24224 KB Output is correct
44 Correct 54 ms 24532 KB Output is correct
45 Correct 58 ms 24716 KB Output is correct
46 Correct 33 ms 26308 KB Output is correct
47 Correct 46 ms 24688 KB Output is correct
48 Correct 47 ms 24660 KB Output is correct
49 Correct 44 ms 24388 KB Output is correct
50 Correct 46 ms 24504 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 74 ms 26692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 2 ms 1228 KB Output is correct
3 Correct 1 ms 844 KB Output is correct
4 Correct 1 ms 972 KB Output is correct
5 Correct 2 ms 1740 KB Output is correct
6 Correct 1 ms 1420 KB Output is correct
7 Correct 2 ms 1100 KB Output is correct
8 Correct 2 ms 1868 KB Output is correct
9 Correct 1 ms 1652 KB Output is correct
10 Correct 4 ms 3532 KB Output is correct
11 Correct 4 ms 3532 KB Output is correct
12 Correct 4 ms 3572 KB Output is correct
13 Correct 3 ms 3148 KB Output is correct
14 Correct 4 ms 3404 KB Output is correct
15 Correct 3 ms 3404 KB Output is correct
16 Correct 4 ms 3576 KB Output is correct
17 Correct 2 ms 2416 KB Output is correct
18 Correct 3 ms 3020 KB Output is correct
19 Correct 3 ms 3148 KB Output is correct
20 Correct 4 ms 3524 KB Output is correct
21 Correct 8 ms 6860 KB Output is correct
22 Correct 9 ms 7884 KB Output is correct
23 Correct 6 ms 5580 KB Output is correct
24 Correct 12 ms 9804 KB Output is correct
25 Correct 13 ms 9804 KB Output is correct
26 Correct 13 ms 10316 KB Output is correct
27 Correct 12 ms 10316 KB Output is correct
28 Correct 12 ms 10316 KB Output is correct
29 Correct 12 ms 10316 KB Output is correct
30 Correct 12 ms 10316 KB Output is correct
31 Correct 13 ms 10316 KB Output is correct
32 Correct 13 ms 10436 KB Output is correct
33 Correct 14 ms 10364 KB Output is correct
34 Correct 14 ms 10336 KB Output is correct
35 Correct 14 ms 10288 KB Output is correct
36 Correct 12 ms 10316 KB Output is correct
37 Correct 31 ms 19976 KB Output is correct
38 Correct 30 ms 20020 KB Output is correct
39 Correct 31 ms 24172 KB Output is correct
40 Correct 49 ms 26564 KB Output is correct
41 Correct 33 ms 26328 KB Output is correct
42 Correct 46 ms 24504 KB Output is correct
43 Correct 52 ms 24224 KB Output is correct
44 Correct 54 ms 24532 KB Output is correct
45 Correct 58 ms 24716 KB Output is correct
46 Correct 33 ms 26308 KB Output is correct
47 Correct 46 ms 24688 KB Output is correct
48 Correct 47 ms 24660 KB Output is correct
49 Correct 44 ms 24388 KB Output is correct
50 Correct 46 ms 24504 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 74 ms 26692 KB Output is correct
53 Correct 73 ms 29596 KB Output is correct
54 Correct 94 ms 34528 KB Output is correct
55 Correct 111 ms 34760 KB Output is correct
56 Correct 69 ms 30300 KB Output is correct
57 Correct 115 ms 34808 KB Output is correct
58 Correct 83 ms 34628 KB Output is correct
59 Correct 93 ms 34600 KB Output is correct
60 Correct 1 ms 332 KB Output is correct
61 Correct 101 ms 34664 KB Output is correct
62 Correct 96 ms 31836 KB Output is correct
63 Correct 107 ms 31868 KB Output is correct
64 Correct 96 ms 31212 KB Output is correct
65 Correct 53 ms 30788 KB Output is correct
66 Correct 46 ms 30376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 2 ms 1228 KB Output is correct
3 Correct 1 ms 844 KB Output is correct
4 Correct 1 ms 972 KB Output is correct
5 Correct 2 ms 1740 KB Output is correct
6 Correct 1 ms 1420 KB Output is correct
7 Correct 2 ms 1100 KB Output is correct
8 Correct 2 ms 1868 KB Output is correct
9 Correct 1 ms 1652 KB Output is correct
10 Correct 4 ms 3532 KB Output is correct
11 Correct 4 ms 3532 KB Output is correct
12 Correct 4 ms 3572 KB Output is correct
13 Correct 3 ms 3148 KB Output is correct
14 Correct 4 ms 3404 KB Output is correct
15 Correct 3 ms 3404 KB Output is correct
16 Correct 4 ms 3576 KB Output is correct
17 Correct 2 ms 2416 KB Output is correct
18 Correct 3 ms 3020 KB Output is correct
19 Correct 3 ms 3148 KB Output is correct
20 Correct 4 ms 3524 KB Output is correct
21 Correct 8 ms 6860 KB Output is correct
22 Correct 9 ms 7884 KB Output is correct
23 Correct 6 ms 5580 KB Output is correct
24 Correct 12 ms 9804 KB Output is correct
25 Correct 13 ms 9804 KB Output is correct
26 Correct 13 ms 10316 KB Output is correct
27 Correct 12 ms 10316 KB Output is correct
28 Correct 12 ms 10316 KB Output is correct
29 Correct 12 ms 10316 KB Output is correct
30 Correct 12 ms 10316 KB Output is correct
31 Correct 13 ms 10316 KB Output is correct
32 Correct 13 ms 10436 KB Output is correct
33 Correct 14 ms 10364 KB Output is correct
34 Correct 14 ms 10336 KB Output is correct
35 Correct 14 ms 10288 KB Output is correct
36 Correct 12 ms 10316 KB Output is correct
37 Correct 31 ms 19976 KB Output is correct
38 Correct 30 ms 20020 KB Output is correct
39 Correct 31 ms 24172 KB Output is correct
40 Correct 49 ms 26564 KB Output is correct
41 Correct 33 ms 26328 KB Output is correct
42 Correct 46 ms 24504 KB Output is correct
43 Correct 52 ms 24224 KB Output is correct
44 Correct 54 ms 24532 KB Output is correct
45 Correct 58 ms 24716 KB Output is correct
46 Correct 33 ms 26308 KB Output is correct
47 Correct 46 ms 24688 KB Output is correct
48 Correct 47 ms 24660 KB Output is correct
49 Correct 44 ms 24388 KB Output is correct
50 Correct 46 ms 24504 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 74 ms 26692 KB Output is correct
53 Correct 73 ms 29596 KB Output is correct
54 Correct 94 ms 34528 KB Output is correct
55 Correct 111 ms 34760 KB Output is correct
56 Correct 69 ms 30300 KB Output is correct
57 Correct 115 ms 34808 KB Output is correct
58 Correct 83 ms 34628 KB Output is correct
59 Correct 93 ms 34600 KB Output is correct
60 Correct 1 ms 332 KB Output is correct
61 Correct 101 ms 34664 KB Output is correct
62 Correct 96 ms 31836 KB Output is correct
63 Correct 107 ms 31868 KB Output is correct
64 Correct 96 ms 31212 KB Output is correct
65 Correct 53 ms 30788 KB Output is correct
66 Correct 46 ms 30376 KB Output is correct
67 Correct 123 ms 39456 KB Output is correct
68 Correct 67 ms 47936 KB Output is correct
69 Correct 255 ms 48980 KB Output is correct
70 Correct 196 ms 48704 KB Output is correct
71 Correct 203 ms 48564 KB Output is correct
72 Correct 65 ms 47804 KB Output is correct
73 Correct 66 ms 47776 KB Output is correct
74 Correct 268 ms 48972 KB Output is correct
75 Correct 243 ms 48692 KB Output is correct
76 Correct 255 ms 49048 KB Output is correct
77 Correct 279 ms 49124 KB Output is correct