답안 #502077

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
502077 2022-01-05T08:43:07 Z syrtin Bootfall (IZhO17_bootfall) C++17
100 / 100
929 ms 1048 KB
#include <bits/stdc++.h>
#define pb push_back
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair < int, int > pii;
typedef vector<int> vi;
typedef vector<long long> vll;
const int N = 250000 / 2 + 1;
const ll mod = 250001;
void solve(){
	int n;
	cin >> n;
	int a[n], x = 0;
	bitset<N> can;
	bool ok = 0, okk = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		if(a[i] % 2)ok = 1;
		else okk = 1;
		x += a[i];
	}
	bitset<mod> hv;
	hv[0] = 1;
	for(int j = 0; j < n; j++) {
		hv |= (hv << a[j]);
	}
	if(x % 2 || !hv[x / 2] || ok & okk) {
		cout << "0";
		return;
	}
	x -= a[0];
	if(x % 2)ok = 1;
	else ok = 0;
	x += a[0];
	for(int i = 0; i < N; i++) can[i] = 1;
	sort(a, a + n);
	for(int i = 0; i < n; i++) {
		if(i && a[i] == a[i - 1])continue;
		hv.reset();
		hv[0] = 1;
		for(int j = 0; j < n; j++) {
			if(j == i)continue;
			hv |= (hv << a[j]);
		}
		x -= a[i];
		for(int p = can._Find_first(); p != can.size(); p = can._Find_next(p)) {
			int t = p * 2 + ok;
			if(!hv[(x + t) / 2] && ((x + t) / 2 - t < 0 || !hv[(x + t) / 2 - t])) can[p] = 0;
		}
		x += a[i];
	}
	cout << can.count() << '\n';
	for(int p = can._Find_first(); p != can.size(); p = can._Find_next(p)) {
		cout << p * 2 + ok << ' ';
	}	
}
int main() {
    //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
    int times = 1;
	//cin >> times;
    while(times--)solve();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 3 ms 332 KB Output is correct
6 Correct 2 ms 416 KB Output is correct
7 Correct 2 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 3 ms 332 KB Output is correct
6 Correct 2 ms 416 KB Output is correct
7 Correct 2 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 3 ms 332 KB Output is correct
12 Correct 4 ms 416 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 3 ms 332 KB Output is correct
15 Correct 3 ms 412 KB Output is correct
16 Correct 5 ms 332 KB Output is correct
17 Correct 3 ms 412 KB Output is correct
18 Correct 3 ms 332 KB Output is correct
19 Correct 3 ms 364 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 3 ms 332 KB Output is correct
6 Correct 2 ms 416 KB Output is correct
7 Correct 2 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 3 ms 332 KB Output is correct
12 Correct 4 ms 416 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 3 ms 332 KB Output is correct
15 Correct 3 ms 412 KB Output is correct
16 Correct 5 ms 332 KB Output is correct
17 Correct 3 ms 412 KB Output is correct
18 Correct 3 ms 332 KB Output is correct
19 Correct 3 ms 364 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 16 ms 332 KB Output is correct
22 Correct 21 ms 416 KB Output is correct
23 Correct 14 ms 416 KB Output is correct
24 Correct 28 ms 404 KB Output is correct
25 Correct 7 ms 412 KB Output is correct
26 Correct 6 ms 332 KB Output is correct
27 Correct 6 ms 332 KB Output is correct
28 Correct 5 ms 332 KB Output is correct
29 Correct 6 ms 332 KB Output is correct
30 Correct 1 ms 416 KB Output is correct
31 Correct 20 ms 416 KB Output is correct
32 Correct 32 ms 408 KB Output is correct
33 Correct 3 ms 332 KB Output is correct
34 Correct 3 ms 332 KB Output is correct
35 Correct 4 ms 332 KB Output is correct
36 Correct 36 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 3 ms 332 KB Output is correct
6 Correct 2 ms 416 KB Output is correct
7 Correct 2 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 3 ms 332 KB Output is correct
12 Correct 4 ms 416 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 3 ms 332 KB Output is correct
15 Correct 3 ms 412 KB Output is correct
16 Correct 5 ms 332 KB Output is correct
17 Correct 3 ms 412 KB Output is correct
18 Correct 3 ms 332 KB Output is correct
19 Correct 3 ms 364 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 16 ms 332 KB Output is correct
22 Correct 21 ms 416 KB Output is correct
23 Correct 14 ms 416 KB Output is correct
24 Correct 28 ms 404 KB Output is correct
25 Correct 7 ms 412 KB Output is correct
26 Correct 6 ms 332 KB Output is correct
27 Correct 6 ms 332 KB Output is correct
28 Correct 5 ms 332 KB Output is correct
29 Correct 6 ms 332 KB Output is correct
30 Correct 1 ms 416 KB Output is correct
31 Correct 20 ms 416 KB Output is correct
32 Correct 32 ms 408 KB Output is correct
33 Correct 3 ms 332 KB Output is correct
34 Correct 3 ms 332 KB Output is correct
35 Correct 4 ms 332 KB Output is correct
36 Correct 36 ms 332 KB Output is correct
37 Correct 73 ms 580 KB Output is correct
38 Correct 74 ms 452 KB Output is correct
39 Correct 5 ms 332 KB Output is correct
40 Correct 243 ms 416 KB Output is correct
41 Correct 5 ms 332 KB Output is correct
42 Correct 192 ms 404 KB Output is correct
43 Correct 48 ms 536 KB Output is correct
44 Correct 48 ms 536 KB Output is correct
45 Correct 49 ms 540 KB Output is correct
46 Correct 234 ms 400 KB Output is correct
47 Correct 189 ms 396 KB Output is correct
48 Correct 14 ms 412 KB Output is correct
49 Correct 9 ms 332 KB Output is correct
50 Correct 211 ms 392 KB Output is correct
51 Correct 3 ms 332 KB Output is correct
52 Correct 27 ms 532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 3 ms 332 KB Output is correct
6 Correct 2 ms 416 KB Output is correct
7 Correct 2 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 3 ms 332 KB Output is correct
12 Correct 4 ms 416 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 3 ms 332 KB Output is correct
15 Correct 3 ms 412 KB Output is correct
16 Correct 5 ms 332 KB Output is correct
17 Correct 3 ms 412 KB Output is correct
18 Correct 3 ms 332 KB Output is correct
19 Correct 3 ms 364 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 16 ms 332 KB Output is correct
22 Correct 21 ms 416 KB Output is correct
23 Correct 14 ms 416 KB Output is correct
24 Correct 28 ms 404 KB Output is correct
25 Correct 7 ms 412 KB Output is correct
26 Correct 6 ms 332 KB Output is correct
27 Correct 6 ms 332 KB Output is correct
28 Correct 5 ms 332 KB Output is correct
29 Correct 6 ms 332 KB Output is correct
30 Correct 1 ms 416 KB Output is correct
31 Correct 20 ms 416 KB Output is correct
32 Correct 32 ms 408 KB Output is correct
33 Correct 3 ms 332 KB Output is correct
34 Correct 3 ms 332 KB Output is correct
35 Correct 4 ms 332 KB Output is correct
36 Correct 36 ms 332 KB Output is correct
37 Correct 73 ms 580 KB Output is correct
38 Correct 74 ms 452 KB Output is correct
39 Correct 5 ms 332 KB Output is correct
40 Correct 243 ms 416 KB Output is correct
41 Correct 5 ms 332 KB Output is correct
42 Correct 192 ms 404 KB Output is correct
43 Correct 48 ms 536 KB Output is correct
44 Correct 48 ms 536 KB Output is correct
45 Correct 49 ms 540 KB Output is correct
46 Correct 234 ms 400 KB Output is correct
47 Correct 189 ms 396 KB Output is correct
48 Correct 14 ms 412 KB Output is correct
49 Correct 9 ms 332 KB Output is correct
50 Correct 211 ms 392 KB Output is correct
51 Correct 3 ms 332 KB Output is correct
52 Correct 27 ms 532 KB Output is correct
53 Correct 240 ms 408 KB Output is correct
54 Correct 312 ms 536 KB Output is correct
55 Correct 42 ms 652 KB Output is correct
56 Correct 295 ms 528 KB Output is correct
57 Correct 49 ms 652 KB Output is correct
58 Correct 420 ms 528 KB Output is correct
59 Correct 240 ms 536 KB Output is correct
60 Correct 3 ms 416 KB Output is correct
61 Correct 242 ms 528 KB Output is correct
62 Correct 131 ms 580 KB Output is correct
63 Correct 68 ms 656 KB Output is correct
64 Correct 67 ms 664 KB Output is correct
65 Correct 21 ms 412 KB Output is correct
66 Correct 86 ms 396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 3 ms 332 KB Output is correct
6 Correct 2 ms 416 KB Output is correct
7 Correct 2 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 3 ms 332 KB Output is correct
12 Correct 4 ms 416 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 3 ms 332 KB Output is correct
15 Correct 3 ms 412 KB Output is correct
16 Correct 5 ms 332 KB Output is correct
17 Correct 3 ms 412 KB Output is correct
18 Correct 3 ms 332 KB Output is correct
19 Correct 3 ms 364 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 16 ms 332 KB Output is correct
22 Correct 21 ms 416 KB Output is correct
23 Correct 14 ms 416 KB Output is correct
24 Correct 28 ms 404 KB Output is correct
25 Correct 7 ms 412 KB Output is correct
26 Correct 6 ms 332 KB Output is correct
27 Correct 6 ms 332 KB Output is correct
28 Correct 5 ms 332 KB Output is correct
29 Correct 6 ms 332 KB Output is correct
30 Correct 1 ms 416 KB Output is correct
31 Correct 20 ms 416 KB Output is correct
32 Correct 32 ms 408 KB Output is correct
33 Correct 3 ms 332 KB Output is correct
34 Correct 3 ms 332 KB Output is correct
35 Correct 4 ms 332 KB Output is correct
36 Correct 36 ms 332 KB Output is correct
37 Correct 73 ms 580 KB Output is correct
38 Correct 74 ms 452 KB Output is correct
39 Correct 5 ms 332 KB Output is correct
40 Correct 243 ms 416 KB Output is correct
41 Correct 5 ms 332 KB Output is correct
42 Correct 192 ms 404 KB Output is correct
43 Correct 48 ms 536 KB Output is correct
44 Correct 48 ms 536 KB Output is correct
45 Correct 49 ms 540 KB Output is correct
46 Correct 234 ms 400 KB Output is correct
47 Correct 189 ms 396 KB Output is correct
48 Correct 14 ms 412 KB Output is correct
49 Correct 9 ms 332 KB Output is correct
50 Correct 211 ms 392 KB Output is correct
51 Correct 3 ms 332 KB Output is correct
52 Correct 27 ms 532 KB Output is correct
53 Correct 240 ms 408 KB Output is correct
54 Correct 312 ms 536 KB Output is correct
55 Correct 42 ms 652 KB Output is correct
56 Correct 295 ms 528 KB Output is correct
57 Correct 49 ms 652 KB Output is correct
58 Correct 420 ms 528 KB Output is correct
59 Correct 240 ms 536 KB Output is correct
60 Correct 3 ms 416 KB Output is correct
61 Correct 242 ms 528 KB Output is correct
62 Correct 131 ms 580 KB Output is correct
63 Correct 68 ms 656 KB Output is correct
64 Correct 67 ms 664 KB Output is correct
65 Correct 21 ms 412 KB Output is correct
66 Correct 86 ms 396 KB Output is correct
67 Correct 586 ms 524 KB Output is correct
68 Correct 6 ms 332 KB Output is correct
69 Correct 114 ms 1048 KB Output is correct
70 Correct 914 ms 776 KB Output is correct
71 Correct 929 ms 796 KB Output is correct
72 Correct 6 ms 332 KB Output is correct
73 Correct 5 ms 332 KB Output is correct
74 Correct 212 ms 1036 KB Output is correct
75 Correct 535 ms 912 KB Output is correct
76 Correct 53 ms 964 KB Output is correct
77 Correct 107 ms 1040 KB Output is correct