답안 #949404

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
949404 2024-03-19T08:03:14 Z hqminhuwu Bootfall (IZhO17_bootfall) C++14
100 / 100
446 ms 31824 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pll;
typedef pair <int,int> pii;
typedef pair <int,pii> piii;

#define forr(_a,_b,_c) for(int _a = (_b); _a <= (_c); ++_a)
#define ford(_a,_b,_c) for(int _a = (_b) + 1; _a --> (_c);)
#define forf(_a,_b,_c) for(int _a = (_b); _a < (_c); ++_a)
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define all(x) begin(x),end(x)
#define mask(i) (1LL << (i))
#define bit(x, i) (((x) >> (i)) & 1)
#define bp __builtin_popcountll
#define file "test"

const int N = 5e2 + 5;
const ll oo = 1e9;
const ll mod = 1e9 + 7;
const int lmt = 250001;

bitset <lmt> res, pre[N], suf[N], tmp;
int n, a[N], sum, cnt[4];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	#ifdef hqm
		freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);
	#endif

	cin >> n;
	forr (i, 1, n)
		cin >> a[i], sum += a[i], cnt[a[i] & 1]++;
	
	pre[0][0] = 1;
	suf[n + 1][0] = 1;
	forr (i, 1, n)	pre[i] = pre[i - 1] | (pre[i - 1] << a[i]);
	ford (i, n, 1)	suf[i] = suf[i + 1] | (suf[i + 1] << a[i]);

	if (sum % 2 || !pre[n][sum / 2] || min(cnt[0], cnt[1]) > 0){
		cout << 0;
		return 0;
	}

	res.set();

	forr (i, 1, n){
		if (i * 2 <= n){
			tmp = suf[i + 1];
			ford (j, i - 1, 1)
				tmp |= tmp << a[j];
		}
		else {
			tmp = pre[i - 1];
			forr (j, i + 1, n)
				tmp |= tmp << a[j];
		}

		int nsum = sum - a[i];
		if (cnt[0])
			res &= tmp >> (nsum / 2);
		else res &= tmp >> (nsum / 2 + 1);
	}
	
	if (cnt[0])
		res[0] = 0;
		
	cout << res.count() << "\n";
	forf (i, 0, lmt){
		if (res[i])
			cout << i * 2 + (cnt[1] != 0) << " ";
	}
	return 0;
}
/*



*/

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4700 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 4700 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 2 ms 4620 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 2 ms 4700 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4700 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 4700 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 2 ms 4620 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 2 ms 4700 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 3 ms 4700 KB Output is correct
11 Correct 3 ms 4700 KB Output is correct
12 Correct 3 ms 4816 KB Output is correct
13 Correct 2 ms 4700 KB Output is correct
14 Correct 3 ms 4700 KB Output is correct
15 Correct 5 ms 4816 KB Output is correct
16 Correct 3 ms 4700 KB Output is correct
17 Correct 3 ms 4696 KB Output is correct
18 Correct 2 ms 4696 KB Output is correct
19 Correct 3 ms 4700 KB Output is correct
20 Correct 3 ms 4700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4700 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 4700 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 2 ms 4620 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 2 ms 4700 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 3 ms 4700 KB Output is correct
11 Correct 3 ms 4700 KB Output is correct
12 Correct 3 ms 4816 KB Output is correct
13 Correct 2 ms 4700 KB Output is correct
14 Correct 3 ms 4700 KB Output is correct
15 Correct 5 ms 4816 KB Output is correct
16 Correct 3 ms 4700 KB Output is correct
17 Correct 3 ms 4696 KB Output is correct
18 Correct 2 ms 4696 KB Output is correct
19 Correct 3 ms 4700 KB Output is correct
20 Correct 3 ms 4700 KB Output is correct
21 Correct 9 ms 6748 KB Output is correct
22 Correct 12 ms 8924 KB Output is correct
23 Correct 7 ms 6748 KB Output is correct
24 Correct 17 ms 8724 KB Output is correct
25 Correct 17 ms 8792 KB Output is correct
26 Correct 19 ms 8908 KB Output is correct
27 Correct 19 ms 9048 KB Output is correct
28 Correct 19 ms 8796 KB Output is correct
29 Correct 20 ms 8796 KB Output is correct
30 Correct 3 ms 8796 KB Output is correct
31 Correct 20 ms 8920 KB Output is correct
32 Correct 19 ms 8912 KB Output is correct
33 Correct 19 ms 8792 KB Output is correct
34 Correct 20 ms 8792 KB Output is correct
35 Correct 22 ms 8920 KB Output is correct
36 Correct 20 ms 8796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4700 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 4700 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 2 ms 4620 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 2 ms 4700 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 3 ms 4700 KB Output is correct
11 Correct 3 ms 4700 KB Output is correct
12 Correct 3 ms 4816 KB Output is correct
13 Correct 2 ms 4700 KB Output is correct
14 Correct 3 ms 4700 KB Output is correct
15 Correct 5 ms 4816 KB Output is correct
16 Correct 3 ms 4700 KB Output is correct
17 Correct 3 ms 4696 KB Output is correct
18 Correct 2 ms 4696 KB Output is correct
19 Correct 3 ms 4700 KB Output is correct
20 Correct 3 ms 4700 KB Output is correct
21 Correct 9 ms 6748 KB Output is correct
22 Correct 12 ms 8924 KB Output is correct
23 Correct 7 ms 6748 KB Output is correct
24 Correct 17 ms 8724 KB Output is correct
25 Correct 17 ms 8792 KB Output is correct
26 Correct 19 ms 8908 KB Output is correct
27 Correct 19 ms 9048 KB Output is correct
28 Correct 19 ms 8796 KB Output is correct
29 Correct 20 ms 8796 KB Output is correct
30 Correct 3 ms 8796 KB Output is correct
31 Correct 20 ms 8920 KB Output is correct
32 Correct 19 ms 8912 KB Output is correct
33 Correct 19 ms 8792 KB Output is correct
34 Correct 20 ms 8792 KB Output is correct
35 Correct 22 ms 8920 KB Output is correct
36 Correct 20 ms 8796 KB Output is correct
37 Correct 71 ms 14940 KB Output is correct
38 Correct 71 ms 15068 KB Output is correct
39 Correct 117 ms 19036 KB Output is correct
40 Correct 124 ms 19156 KB Output is correct
41 Correct 133 ms 19168 KB Output is correct
42 Correct 108 ms 19036 KB Output is correct
43 Correct 113 ms 19152 KB Output is correct
44 Correct 110 ms 19284 KB Output is correct
45 Correct 112 ms 19148 KB Output is correct
46 Correct 123 ms 19152 KB Output is correct
47 Correct 118 ms 19032 KB Output is correct
48 Correct 107 ms 19152 KB Output is correct
49 Correct 113 ms 19152 KB Output is correct
50 Correct 111 ms 19152 KB Output is correct
51 Correct 7 ms 19036 KB Output is correct
52 Correct 134 ms 19152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4700 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 4700 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 2 ms 4620 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 2 ms 4700 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 3 ms 4700 KB Output is correct
11 Correct 3 ms 4700 KB Output is correct
12 Correct 3 ms 4816 KB Output is correct
13 Correct 2 ms 4700 KB Output is correct
14 Correct 3 ms 4700 KB Output is correct
15 Correct 5 ms 4816 KB Output is correct
16 Correct 3 ms 4700 KB Output is correct
17 Correct 3 ms 4696 KB Output is correct
18 Correct 2 ms 4696 KB Output is correct
19 Correct 3 ms 4700 KB Output is correct
20 Correct 3 ms 4700 KB Output is correct
21 Correct 9 ms 6748 KB Output is correct
22 Correct 12 ms 8924 KB Output is correct
23 Correct 7 ms 6748 KB Output is correct
24 Correct 17 ms 8724 KB Output is correct
25 Correct 17 ms 8792 KB Output is correct
26 Correct 19 ms 8908 KB Output is correct
27 Correct 19 ms 9048 KB Output is correct
28 Correct 19 ms 8796 KB Output is correct
29 Correct 20 ms 8796 KB Output is correct
30 Correct 3 ms 8796 KB Output is correct
31 Correct 20 ms 8920 KB Output is correct
32 Correct 19 ms 8912 KB Output is correct
33 Correct 19 ms 8792 KB Output is correct
34 Correct 20 ms 8792 KB Output is correct
35 Correct 22 ms 8920 KB Output is correct
36 Correct 20 ms 8796 KB Output is correct
37 Correct 71 ms 14940 KB Output is correct
38 Correct 71 ms 15068 KB Output is correct
39 Correct 117 ms 19036 KB Output is correct
40 Correct 124 ms 19156 KB Output is correct
41 Correct 133 ms 19168 KB Output is correct
42 Correct 108 ms 19036 KB Output is correct
43 Correct 113 ms 19152 KB Output is correct
44 Correct 110 ms 19284 KB Output is correct
45 Correct 112 ms 19148 KB Output is correct
46 Correct 123 ms 19152 KB Output is correct
47 Correct 118 ms 19032 KB Output is correct
48 Correct 107 ms 19152 KB Output is correct
49 Correct 113 ms 19152 KB Output is correct
50 Correct 111 ms 19152 KB Output is correct
51 Correct 7 ms 19036 KB Output is correct
52 Correct 134 ms 19152 KB Output is correct
53 Correct 158 ms 21200 KB Output is correct
54 Correct 209 ms 25312 KB Output is correct
55 Correct 203 ms 25392 KB Output is correct
56 Correct 163 ms 23256 KB Output is correct
57 Correct 220 ms 25424 KB Output is correct
58 Correct 202 ms 25320 KB Output is correct
59 Correct 204 ms 25428 KB Output is correct
60 Correct 11 ms 25180 KB Output is correct
61 Correct 236 ms 25328 KB Output is correct
62 Correct 174 ms 23512 KB Output is correct
63 Correct 171 ms 23380 KB Output is correct
64 Correct 165 ms 23512 KB Output is correct
65 Correct 167 ms 23256 KB Output is correct
66 Correct 158 ms 23256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4700 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 4700 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 2 ms 4620 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 2 ms 4700 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 3 ms 4700 KB Output is correct
11 Correct 3 ms 4700 KB Output is correct
12 Correct 3 ms 4816 KB Output is correct
13 Correct 2 ms 4700 KB Output is correct
14 Correct 3 ms 4700 KB Output is correct
15 Correct 5 ms 4816 KB Output is correct
16 Correct 3 ms 4700 KB Output is correct
17 Correct 3 ms 4696 KB Output is correct
18 Correct 2 ms 4696 KB Output is correct
19 Correct 3 ms 4700 KB Output is correct
20 Correct 3 ms 4700 KB Output is correct
21 Correct 9 ms 6748 KB Output is correct
22 Correct 12 ms 8924 KB Output is correct
23 Correct 7 ms 6748 KB Output is correct
24 Correct 17 ms 8724 KB Output is correct
25 Correct 17 ms 8792 KB Output is correct
26 Correct 19 ms 8908 KB Output is correct
27 Correct 19 ms 9048 KB Output is correct
28 Correct 19 ms 8796 KB Output is correct
29 Correct 20 ms 8796 KB Output is correct
30 Correct 3 ms 8796 KB Output is correct
31 Correct 20 ms 8920 KB Output is correct
32 Correct 19 ms 8912 KB Output is correct
33 Correct 19 ms 8792 KB Output is correct
34 Correct 20 ms 8792 KB Output is correct
35 Correct 22 ms 8920 KB Output is correct
36 Correct 20 ms 8796 KB Output is correct
37 Correct 71 ms 14940 KB Output is correct
38 Correct 71 ms 15068 KB Output is correct
39 Correct 117 ms 19036 KB Output is correct
40 Correct 124 ms 19156 KB Output is correct
41 Correct 133 ms 19168 KB Output is correct
42 Correct 108 ms 19036 KB Output is correct
43 Correct 113 ms 19152 KB Output is correct
44 Correct 110 ms 19284 KB Output is correct
45 Correct 112 ms 19148 KB Output is correct
46 Correct 123 ms 19152 KB Output is correct
47 Correct 118 ms 19032 KB Output is correct
48 Correct 107 ms 19152 KB Output is correct
49 Correct 113 ms 19152 KB Output is correct
50 Correct 111 ms 19152 KB Output is correct
51 Correct 7 ms 19036 KB Output is correct
52 Correct 134 ms 19152 KB Output is correct
53 Correct 158 ms 21200 KB Output is correct
54 Correct 209 ms 25312 KB Output is correct
55 Correct 203 ms 25392 KB Output is correct
56 Correct 163 ms 23256 KB Output is correct
57 Correct 220 ms 25424 KB Output is correct
58 Correct 202 ms 25320 KB Output is correct
59 Correct 204 ms 25428 KB Output is correct
60 Correct 11 ms 25180 KB Output is correct
61 Correct 236 ms 25328 KB Output is correct
62 Correct 174 ms 23512 KB Output is correct
63 Correct 171 ms 23380 KB Output is correct
64 Correct 165 ms 23512 KB Output is correct
65 Correct 167 ms 23256 KB Output is correct
66 Correct 158 ms 23256 KB Output is correct
67 Correct 267 ms 27356 KB Output is correct
68 Correct 12 ms 31068 KB Output is correct
69 Correct 415 ms 31816 KB Output is correct
70 Correct 430 ms 31568 KB Output is correct
71 Correct 409 ms 31572 KB Output is correct
72 Correct 12 ms 31068 KB Output is correct
73 Correct 12 ms 31084 KB Output is correct
74 Correct 411 ms 31744 KB Output is correct
75 Correct 446 ms 31572 KB Output is correct
76 Correct 419 ms 31824 KB Output is correct
77 Correct 426 ms 31812 KB Output is correct