#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <queue>
#include <cstring>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
using namespace std;
#define pii pair<int, int>
#define f first
#define s second
#define ll long long
#define rint int32_t
const int siz = 125001;
rint main() {
cin.tie(0);
ios_base::sync_with_stdio(0);
int n;
cin >> n;
int raw [n];
for (int i = 0; i < n; i++) cin >> raw[i];
bitset<siz> check(0);
check[0] = 1;
int checkSum = 0;
for (int i = 0; i < n; i++) {
check |= check<<raw[i];
checkSum += raw[i];
}
if (checkSum%2 == 1 or check[checkSum/2] == 0) {
cout << 0;
return 0;
}
bitset<siz> startToEnd [n];
startToEnd[0] = bitset<siz>(0);
startToEnd[0][0] = 1;
for (int i = 1; i < n; i++) {
startToEnd[i] = startToEnd[i-1]|(startToEnd[i-1]<<raw[i-1]);
}
bitset<siz> endToStart [n];
endToStart[n-1] = bitset<siz>(0);
endToStart[n-1][0] = 1;
for (int i = n-2; i >= 0; i--) {
endToStart[i] = endToStart[i+1]|(endToStart[i+1]<<raw[i+1]);
}
bitset<siz> even;
bitset<siz> uneven;
even.set();
uneven.set();
even[0] = 0;
bool evenKilled = false;
bool unevenKilled = false;
bitset<siz> cur;
int locSum;
for (int i = 0; i < n; i++) {
cur = startToEnd[i];
for (int j = i+1; j < n; j++) cur |= cur<<raw[j];
locSum = checkSum-raw[i];
if (locSum%2 == 0) {
even &= cur>>(locSum/2);
if (!unevenKilled) {
uneven &= 0;
unevenKilled = true;
}
}
else {
uneven &= cur>>(locSum/2+1);
if (!evenKilled) {
even &= 0;
evenKilled = true;
}
}
}
cout << even.count()+uneven.count() << endl;
for (int i = 0; i < siz; i++) {
if (even[i]) cout << i*2 << " ";
if (uneven[i]) cout << i*2+1 << " ";
}
int d = 0;
d++;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
2 ms |
716 KB |
Output is correct |
6 |
Correct |
1 ms |
588 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
2 ms |
716 KB |
Output is correct |
9 |
Correct |
1 ms |
588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
2 ms |
716 KB |
Output is correct |
6 |
Correct |
1 ms |
588 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
2 ms |
716 KB |
Output is correct |
9 |
Correct |
1 ms |
588 KB |
Output is correct |
10 |
Correct |
4 ms |
1228 KB |
Output is correct |
11 |
Correct |
4 ms |
1228 KB |
Output is correct |
12 |
Correct |
4 ms |
1228 KB |
Output is correct |
13 |
Correct |
3 ms |
1100 KB |
Output is correct |
14 |
Correct |
4 ms |
1228 KB |
Output is correct |
15 |
Correct |
4 ms |
1252 KB |
Output is correct |
16 |
Correct |
4 ms |
1228 KB |
Output is correct |
17 |
Correct |
2 ms |
844 KB |
Output is correct |
18 |
Correct |
3 ms |
1100 KB |
Output is correct |
19 |
Correct |
4 ms |
1100 KB |
Output is correct |
20 |
Correct |
4 ms |
1228 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
2 ms |
716 KB |
Output is correct |
6 |
Correct |
1 ms |
588 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
2 ms |
716 KB |
Output is correct |
9 |
Correct |
1 ms |
588 KB |
Output is correct |
10 |
Correct |
4 ms |
1228 KB |
Output is correct |
11 |
Correct |
4 ms |
1228 KB |
Output is correct |
12 |
Correct |
4 ms |
1228 KB |
Output is correct |
13 |
Correct |
3 ms |
1100 KB |
Output is correct |
14 |
Correct |
4 ms |
1228 KB |
Output is correct |
15 |
Correct |
4 ms |
1252 KB |
Output is correct |
16 |
Correct |
4 ms |
1228 KB |
Output is correct |
17 |
Correct |
2 ms |
844 KB |
Output is correct |
18 |
Correct |
3 ms |
1100 KB |
Output is correct |
19 |
Correct |
4 ms |
1100 KB |
Output is correct |
20 |
Correct |
4 ms |
1228 KB |
Output is correct |
21 |
Correct |
12 ms |
2356 KB |
Output is correct |
22 |
Correct |
16 ms |
2656 KB |
Output is correct |
23 |
Correct |
8 ms |
1928 KB |
Output is correct |
24 |
Correct |
26 ms |
3268 KB |
Output is correct |
25 |
Correct |
24 ms |
3268 KB |
Output is correct |
26 |
Correct |
27 ms |
3456 KB |
Output is correct |
27 |
Correct |
30 ms |
3404 KB |
Output is correct |
28 |
Correct |
27 ms |
3452 KB |
Output is correct |
29 |
Correct |
29 ms |
3452 KB |
Output is correct |
30 |
Correct |
28 ms |
3456 KB |
Output is correct |
31 |
Correct |
27 ms |
3452 KB |
Output is correct |
32 |
Correct |
29 ms |
3452 KB |
Output is correct |
33 |
Correct |
27 ms |
3448 KB |
Output is correct |
34 |
Correct |
27 ms |
3404 KB |
Output is correct |
35 |
Correct |
27 ms |
3404 KB |
Output is correct |
36 |
Correct |
27 ms |
3452 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
2 ms |
716 KB |
Output is correct |
6 |
Correct |
1 ms |
588 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
2 ms |
716 KB |
Output is correct |
9 |
Correct |
1 ms |
588 KB |
Output is correct |
10 |
Correct |
4 ms |
1228 KB |
Output is correct |
11 |
Correct |
4 ms |
1228 KB |
Output is correct |
12 |
Correct |
4 ms |
1228 KB |
Output is correct |
13 |
Correct |
3 ms |
1100 KB |
Output is correct |
14 |
Correct |
4 ms |
1228 KB |
Output is correct |
15 |
Correct |
4 ms |
1252 KB |
Output is correct |
16 |
Correct |
4 ms |
1228 KB |
Output is correct |
17 |
Correct |
2 ms |
844 KB |
Output is correct |
18 |
Correct |
3 ms |
1100 KB |
Output is correct |
19 |
Correct |
4 ms |
1100 KB |
Output is correct |
20 |
Correct |
4 ms |
1228 KB |
Output is correct |
21 |
Correct |
12 ms |
2356 KB |
Output is correct |
22 |
Correct |
16 ms |
2656 KB |
Output is correct |
23 |
Correct |
8 ms |
1928 KB |
Output is correct |
24 |
Correct |
26 ms |
3268 KB |
Output is correct |
25 |
Correct |
24 ms |
3268 KB |
Output is correct |
26 |
Correct |
27 ms |
3456 KB |
Output is correct |
27 |
Correct |
30 ms |
3404 KB |
Output is correct |
28 |
Correct |
27 ms |
3452 KB |
Output is correct |
29 |
Correct |
29 ms |
3452 KB |
Output is correct |
30 |
Correct |
28 ms |
3456 KB |
Output is correct |
31 |
Correct |
27 ms |
3452 KB |
Output is correct |
32 |
Correct |
29 ms |
3452 KB |
Output is correct |
33 |
Correct |
27 ms |
3448 KB |
Output is correct |
34 |
Correct |
27 ms |
3404 KB |
Output is correct |
35 |
Correct |
27 ms |
3404 KB |
Output is correct |
36 |
Correct |
27 ms |
3452 KB |
Output is correct |
37 |
Correct |
109 ms |
6500 KB |
Output is correct |
38 |
Correct |
98 ms |
6492 KB |
Output is correct |
39 |
Correct |
149 ms |
7960 KB |
Output is correct |
40 |
Correct |
178 ms |
8632 KB |
Output is correct |
41 |
Correct |
175 ms |
8652 KB |
Output is correct |
42 |
Correct |
150 ms |
8036 KB |
Output is correct |
43 |
Correct |
146 ms |
8004 KB |
Output is correct |
44 |
Correct |
150 ms |
8088 KB |
Output is correct |
45 |
Correct |
159 ms |
8156 KB |
Output is correct |
46 |
Correct |
173 ms |
8620 KB |
Output is correct |
47 |
Correct |
151 ms |
8080 KB |
Output is correct |
48 |
Correct |
153 ms |
8024 KB |
Output is correct |
49 |
Correct |
150 ms |
8020 KB |
Output is correct |
50 |
Correct |
150 ms |
8036 KB |
Output is correct |
51 |
Correct |
2 ms |
332 KB |
Output is correct |
52 |
Correct |
177 ms |
8768 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
2 ms |
716 KB |
Output is correct |
6 |
Correct |
1 ms |
588 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
2 ms |
716 KB |
Output is correct |
9 |
Correct |
1 ms |
588 KB |
Output is correct |
10 |
Correct |
4 ms |
1228 KB |
Output is correct |
11 |
Correct |
4 ms |
1228 KB |
Output is correct |
12 |
Correct |
4 ms |
1228 KB |
Output is correct |
13 |
Correct |
3 ms |
1100 KB |
Output is correct |
14 |
Correct |
4 ms |
1228 KB |
Output is correct |
15 |
Correct |
4 ms |
1252 KB |
Output is correct |
16 |
Correct |
4 ms |
1228 KB |
Output is correct |
17 |
Correct |
2 ms |
844 KB |
Output is correct |
18 |
Correct |
3 ms |
1100 KB |
Output is correct |
19 |
Correct |
4 ms |
1100 KB |
Output is correct |
20 |
Correct |
4 ms |
1228 KB |
Output is correct |
21 |
Correct |
12 ms |
2356 KB |
Output is correct |
22 |
Correct |
16 ms |
2656 KB |
Output is correct |
23 |
Correct |
8 ms |
1928 KB |
Output is correct |
24 |
Correct |
26 ms |
3268 KB |
Output is correct |
25 |
Correct |
24 ms |
3268 KB |
Output is correct |
26 |
Correct |
27 ms |
3456 KB |
Output is correct |
27 |
Correct |
30 ms |
3404 KB |
Output is correct |
28 |
Correct |
27 ms |
3452 KB |
Output is correct |
29 |
Correct |
29 ms |
3452 KB |
Output is correct |
30 |
Correct |
28 ms |
3456 KB |
Output is correct |
31 |
Correct |
27 ms |
3452 KB |
Output is correct |
32 |
Correct |
29 ms |
3452 KB |
Output is correct |
33 |
Correct |
27 ms |
3448 KB |
Output is correct |
34 |
Correct |
27 ms |
3404 KB |
Output is correct |
35 |
Correct |
27 ms |
3404 KB |
Output is correct |
36 |
Correct |
27 ms |
3452 KB |
Output is correct |
37 |
Correct |
109 ms |
6500 KB |
Output is correct |
38 |
Correct |
98 ms |
6492 KB |
Output is correct |
39 |
Correct |
149 ms |
7960 KB |
Output is correct |
40 |
Correct |
178 ms |
8632 KB |
Output is correct |
41 |
Correct |
175 ms |
8652 KB |
Output is correct |
42 |
Correct |
150 ms |
8036 KB |
Output is correct |
43 |
Correct |
146 ms |
8004 KB |
Output is correct |
44 |
Correct |
150 ms |
8088 KB |
Output is correct |
45 |
Correct |
159 ms |
8156 KB |
Output is correct |
46 |
Correct |
173 ms |
8620 KB |
Output is correct |
47 |
Correct |
151 ms |
8080 KB |
Output is correct |
48 |
Correct |
153 ms |
8024 KB |
Output is correct |
49 |
Correct |
150 ms |
8020 KB |
Output is correct |
50 |
Correct |
150 ms |
8036 KB |
Output is correct |
51 |
Correct |
2 ms |
332 KB |
Output is correct |
52 |
Correct |
177 ms |
8768 KB |
Output is correct |
53 |
Correct |
217 ms |
9676 KB |
Output is correct |
54 |
Correct |
289 ms |
11208 KB |
Output is correct |
55 |
Correct |
294 ms |
11468 KB |
Output is correct |
56 |
Correct |
225 ms |
9804 KB |
Output is correct |
57 |
Correct |
293 ms |
11344 KB |
Output is correct |
58 |
Correct |
291 ms |
11212 KB |
Output is correct |
59 |
Correct |
294 ms |
11220 KB |
Output is correct |
60 |
Correct |
2 ms |
332 KB |
Output is correct |
61 |
Correct |
290 ms |
11224 KB |
Output is correct |
62 |
Correct |
251 ms |
10436 KB |
Output is correct |
63 |
Correct |
245 ms |
10432 KB |
Output is correct |
64 |
Correct |
235 ms |
10180 KB |
Output is correct |
65 |
Correct |
236 ms |
10052 KB |
Output is correct |
66 |
Correct |
233 ms |
9864 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
2 ms |
716 KB |
Output is correct |
6 |
Correct |
1 ms |
588 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
2 ms |
716 KB |
Output is correct |
9 |
Correct |
1 ms |
588 KB |
Output is correct |
10 |
Correct |
4 ms |
1228 KB |
Output is correct |
11 |
Correct |
4 ms |
1228 KB |
Output is correct |
12 |
Correct |
4 ms |
1228 KB |
Output is correct |
13 |
Correct |
3 ms |
1100 KB |
Output is correct |
14 |
Correct |
4 ms |
1228 KB |
Output is correct |
15 |
Correct |
4 ms |
1252 KB |
Output is correct |
16 |
Correct |
4 ms |
1228 KB |
Output is correct |
17 |
Correct |
2 ms |
844 KB |
Output is correct |
18 |
Correct |
3 ms |
1100 KB |
Output is correct |
19 |
Correct |
4 ms |
1100 KB |
Output is correct |
20 |
Correct |
4 ms |
1228 KB |
Output is correct |
21 |
Correct |
12 ms |
2356 KB |
Output is correct |
22 |
Correct |
16 ms |
2656 KB |
Output is correct |
23 |
Correct |
8 ms |
1928 KB |
Output is correct |
24 |
Correct |
26 ms |
3268 KB |
Output is correct |
25 |
Correct |
24 ms |
3268 KB |
Output is correct |
26 |
Correct |
27 ms |
3456 KB |
Output is correct |
27 |
Correct |
30 ms |
3404 KB |
Output is correct |
28 |
Correct |
27 ms |
3452 KB |
Output is correct |
29 |
Correct |
29 ms |
3452 KB |
Output is correct |
30 |
Correct |
28 ms |
3456 KB |
Output is correct |
31 |
Correct |
27 ms |
3452 KB |
Output is correct |
32 |
Correct |
29 ms |
3452 KB |
Output is correct |
33 |
Correct |
27 ms |
3448 KB |
Output is correct |
34 |
Correct |
27 ms |
3404 KB |
Output is correct |
35 |
Correct |
27 ms |
3404 KB |
Output is correct |
36 |
Correct |
27 ms |
3452 KB |
Output is correct |
37 |
Correct |
109 ms |
6500 KB |
Output is correct |
38 |
Correct |
98 ms |
6492 KB |
Output is correct |
39 |
Correct |
149 ms |
7960 KB |
Output is correct |
40 |
Correct |
178 ms |
8632 KB |
Output is correct |
41 |
Correct |
175 ms |
8652 KB |
Output is correct |
42 |
Correct |
150 ms |
8036 KB |
Output is correct |
43 |
Correct |
146 ms |
8004 KB |
Output is correct |
44 |
Correct |
150 ms |
8088 KB |
Output is correct |
45 |
Correct |
159 ms |
8156 KB |
Output is correct |
46 |
Correct |
173 ms |
8620 KB |
Output is correct |
47 |
Correct |
151 ms |
8080 KB |
Output is correct |
48 |
Correct |
153 ms |
8024 KB |
Output is correct |
49 |
Correct |
150 ms |
8020 KB |
Output is correct |
50 |
Correct |
150 ms |
8036 KB |
Output is correct |
51 |
Correct |
2 ms |
332 KB |
Output is correct |
52 |
Correct |
177 ms |
8768 KB |
Output is correct |
53 |
Correct |
217 ms |
9676 KB |
Output is correct |
54 |
Correct |
289 ms |
11208 KB |
Output is correct |
55 |
Correct |
294 ms |
11468 KB |
Output is correct |
56 |
Correct |
225 ms |
9804 KB |
Output is correct |
57 |
Correct |
293 ms |
11344 KB |
Output is correct |
58 |
Correct |
291 ms |
11212 KB |
Output is correct |
59 |
Correct |
294 ms |
11220 KB |
Output is correct |
60 |
Correct |
2 ms |
332 KB |
Output is correct |
61 |
Correct |
290 ms |
11224 KB |
Output is correct |
62 |
Correct |
251 ms |
10436 KB |
Output is correct |
63 |
Correct |
245 ms |
10432 KB |
Output is correct |
64 |
Correct |
235 ms |
10180 KB |
Output is correct |
65 |
Correct |
236 ms |
10052 KB |
Output is correct |
66 |
Correct |
233 ms |
9864 KB |
Output is correct |
67 |
Correct |
375 ms |
12744 KB |
Output is correct |
68 |
Correct |
4 ms |
332 KB |
Output is correct |
69 |
Incorrect |
578 ms |
15696 KB |
Output isn't correct |
70 |
Halted |
0 ms |
0 KB |
- |