#include <bits/stdc++.h>
#define MAX 251000
int array[505];
typedef std::bitset<MAX> bits;
bits permite={};
bool poc[2]={};
///Divide and Conquer
void dnc(int l,int r,int sum, bits atual){
if(l==r){
poc[sum&1]=1;
int meio = sum/2;
permite&=atual>>meio;
return;
}
int m = (l+r)/2;
///Left
{
bits lef;
lef=atual;
int newsum = sum;
for(int i=m+1;i<=r;++i){
lef|=lef<<array[i];
newsum+=array[i];
}
dnc(l,m,newsum,lef);
}
///Right
{
bits rig;
rig=atual;
int newsum = sum;
for(int i=l;i<=m;++i){
rig|=rig<<array[i];
newsum+=array[i];
}
dnc(m+1,r,newsum,rig);
}
}
int main()
{
int N;
std::cin>>N;
for(int i=0;i!=N;++i)std::cin>>array[i];
int t=0;
{
for(auto&x:array)t+=x;
if(t&1){
std::cout<<"0\n";
return 0;
}
bits x = {};
x[0]=1;
for(int i=0;i!=N;++i){
x|=x<<array[i];
}
if(!x[t/2]){
std::cout<<"0\n";
return 0;
}
}
for(int i=0;i!=MAX;++i)permite[i]=1;
bits start={};
start[0]=1;
dnc(0,N-1,0,start);
if(poc[0]==poc[1]){
std::cout<<"0\n";
return 0;
}
std::vector<int> pode;
for(int i=1;i!=MAX;++i){
if(permite[i])pode.push_back(i);
}
std::cout<<pode.size()<<"\n";
for(auto&x:pode){
std::cout<<((x*2)-(array[0]&1))<<" ";
}
std::cout<<"\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
716 KB |
Output is correct |
2 |
Correct |
2 ms |
796 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
716 KB |
Output is correct |
5 |
Correct |
3 ms |
972 KB |
Output is correct |
6 |
Correct |
2 ms |
844 KB |
Output is correct |
7 |
Correct |
2 ms |
844 KB |
Output is correct |
8 |
Correct |
2 ms |
972 KB |
Output is correct |
9 |
Correct |
2 ms |
972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
716 KB |
Output is correct |
2 |
Correct |
2 ms |
796 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
716 KB |
Output is correct |
5 |
Correct |
3 ms |
972 KB |
Output is correct |
6 |
Correct |
2 ms |
844 KB |
Output is correct |
7 |
Correct |
2 ms |
844 KB |
Output is correct |
8 |
Correct |
2 ms |
972 KB |
Output is correct |
9 |
Correct |
2 ms |
972 KB |
Output is correct |
10 |
Correct |
3 ms |
1100 KB |
Output is correct |
11 |
Correct |
4 ms |
1100 KB |
Output is correct |
12 |
Correct |
4 ms |
1100 KB |
Output is correct |
13 |
Correct |
3 ms |
1100 KB |
Output is correct |
14 |
Correct |
4 ms |
1100 KB |
Output is correct |
15 |
Correct |
4 ms |
1152 KB |
Output is correct |
16 |
Correct |
4 ms |
1156 KB |
Output is correct |
17 |
Correct |
3 ms |
1100 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 |
1028 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
716 KB |
Output is correct |
2 |
Correct |
2 ms |
796 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
716 KB |
Output is correct |
5 |
Correct |
3 ms |
972 KB |
Output is correct |
6 |
Correct |
2 ms |
844 KB |
Output is correct |
7 |
Correct |
2 ms |
844 KB |
Output is correct |
8 |
Correct |
2 ms |
972 KB |
Output is correct |
9 |
Correct |
2 ms |
972 KB |
Output is correct |
10 |
Correct |
3 ms |
1100 KB |
Output is correct |
11 |
Correct |
4 ms |
1100 KB |
Output is correct |
12 |
Correct |
4 ms |
1100 KB |
Output is correct |
13 |
Correct |
3 ms |
1100 KB |
Output is correct |
14 |
Correct |
4 ms |
1100 KB |
Output is correct |
15 |
Correct |
4 ms |
1152 KB |
Output is correct |
16 |
Correct |
4 ms |
1156 KB |
Output is correct |
17 |
Correct |
3 ms |
1100 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 |
1028 KB |
Output is correct |
21 |
Correct |
6 ms |
1292 KB |
Output is correct |
22 |
Correct |
10 ms |
1404 KB |
Output is correct |
23 |
Correct |
8 ms |
1228 KB |
Output is correct |
24 |
Correct |
8 ms |
1412 KB |
Output is correct |
25 |
Correct |
9 ms |
1420 KB |
Output is correct |
26 |
Correct |
10 ms |
1396 KB |
Output is correct |
27 |
Correct |
9 ms |
1412 KB |
Output is correct |
28 |
Correct |
9 ms |
1404 KB |
Output is correct |
29 |
Correct |
9 ms |
1356 KB |
Output is correct |
30 |
Correct |
8 ms |
1356 KB |
Output is correct |
31 |
Correct |
9 ms |
1356 KB |
Output is correct |
32 |
Correct |
9 ms |
1404 KB |
Output is correct |
33 |
Correct |
9 ms |
1356 KB |
Output is correct |
34 |
Correct |
8 ms |
1396 KB |
Output is correct |
35 |
Correct |
9 ms |
1392 KB |
Output is correct |
36 |
Correct |
9 ms |
1356 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
716 KB |
Output is correct |
2 |
Correct |
2 ms |
796 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
716 KB |
Output is correct |
5 |
Correct |
3 ms |
972 KB |
Output is correct |
6 |
Correct |
2 ms |
844 KB |
Output is correct |
7 |
Correct |
2 ms |
844 KB |
Output is correct |
8 |
Correct |
2 ms |
972 KB |
Output is correct |
9 |
Correct |
2 ms |
972 KB |
Output is correct |
10 |
Correct |
3 ms |
1100 KB |
Output is correct |
11 |
Correct |
4 ms |
1100 KB |
Output is correct |
12 |
Correct |
4 ms |
1100 KB |
Output is correct |
13 |
Correct |
3 ms |
1100 KB |
Output is correct |
14 |
Correct |
4 ms |
1100 KB |
Output is correct |
15 |
Correct |
4 ms |
1152 KB |
Output is correct |
16 |
Correct |
4 ms |
1156 KB |
Output is correct |
17 |
Correct |
3 ms |
1100 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 |
1028 KB |
Output is correct |
21 |
Correct |
6 ms |
1292 KB |
Output is correct |
22 |
Correct |
10 ms |
1404 KB |
Output is correct |
23 |
Correct |
8 ms |
1228 KB |
Output is correct |
24 |
Correct |
8 ms |
1412 KB |
Output is correct |
25 |
Correct |
9 ms |
1420 KB |
Output is correct |
26 |
Correct |
10 ms |
1396 KB |
Output is correct |
27 |
Correct |
9 ms |
1412 KB |
Output is correct |
28 |
Correct |
9 ms |
1404 KB |
Output is correct |
29 |
Correct |
9 ms |
1356 KB |
Output is correct |
30 |
Correct |
8 ms |
1356 KB |
Output is correct |
31 |
Correct |
9 ms |
1356 KB |
Output is correct |
32 |
Correct |
9 ms |
1404 KB |
Output is correct |
33 |
Correct |
9 ms |
1356 KB |
Output is correct |
34 |
Correct |
8 ms |
1396 KB |
Output is correct |
35 |
Correct |
9 ms |
1392 KB |
Output is correct |
36 |
Correct |
9 ms |
1356 KB |
Output is correct |
37 |
Correct |
18 ms |
1612 KB |
Output is correct |
38 |
Correct |
17 ms |
1648 KB |
Output is correct |
39 |
Correct |
22 ms |
1408 KB |
Output is correct |
40 |
Correct |
25 ms |
1740 KB |
Output is correct |
41 |
Correct |
24 ms |
1644 KB |
Output is correct |
42 |
Correct |
23 ms |
1624 KB |
Output is correct |
43 |
Correct |
24 ms |
1884 KB |
Output is correct |
44 |
Correct |
23 ms |
1868 KB |
Output is correct |
45 |
Correct |
26 ms |
1992 KB |
Output is correct |
46 |
Correct |
23 ms |
1660 KB |
Output is correct |
47 |
Correct |
23 ms |
1640 KB |
Output is correct |
48 |
Correct |
23 ms |
1740 KB |
Output is correct |
49 |
Correct |
21 ms |
1536 KB |
Output is correct |
50 |
Correct |
23 ms |
1640 KB |
Output is correct |
51 |
Correct |
0 ms |
332 KB |
Output is correct |
52 |
Correct |
28 ms |
1956 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
716 KB |
Output is correct |
2 |
Correct |
2 ms |
796 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
716 KB |
Output is correct |
5 |
Correct |
3 ms |
972 KB |
Output is correct |
6 |
Correct |
2 ms |
844 KB |
Output is correct |
7 |
Correct |
2 ms |
844 KB |
Output is correct |
8 |
Correct |
2 ms |
972 KB |
Output is correct |
9 |
Correct |
2 ms |
972 KB |
Output is correct |
10 |
Correct |
3 ms |
1100 KB |
Output is correct |
11 |
Correct |
4 ms |
1100 KB |
Output is correct |
12 |
Correct |
4 ms |
1100 KB |
Output is correct |
13 |
Correct |
3 ms |
1100 KB |
Output is correct |
14 |
Correct |
4 ms |
1100 KB |
Output is correct |
15 |
Correct |
4 ms |
1152 KB |
Output is correct |
16 |
Correct |
4 ms |
1156 KB |
Output is correct |
17 |
Correct |
3 ms |
1100 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 |
1028 KB |
Output is correct |
21 |
Correct |
6 ms |
1292 KB |
Output is correct |
22 |
Correct |
10 ms |
1404 KB |
Output is correct |
23 |
Correct |
8 ms |
1228 KB |
Output is correct |
24 |
Correct |
8 ms |
1412 KB |
Output is correct |
25 |
Correct |
9 ms |
1420 KB |
Output is correct |
26 |
Correct |
10 ms |
1396 KB |
Output is correct |
27 |
Correct |
9 ms |
1412 KB |
Output is correct |
28 |
Correct |
9 ms |
1404 KB |
Output is correct |
29 |
Correct |
9 ms |
1356 KB |
Output is correct |
30 |
Correct |
8 ms |
1356 KB |
Output is correct |
31 |
Correct |
9 ms |
1356 KB |
Output is correct |
32 |
Correct |
9 ms |
1404 KB |
Output is correct |
33 |
Correct |
9 ms |
1356 KB |
Output is correct |
34 |
Correct |
8 ms |
1396 KB |
Output is correct |
35 |
Correct |
9 ms |
1392 KB |
Output is correct |
36 |
Correct |
9 ms |
1356 KB |
Output is correct |
37 |
Correct |
18 ms |
1612 KB |
Output is correct |
38 |
Correct |
17 ms |
1648 KB |
Output is correct |
39 |
Correct |
22 ms |
1408 KB |
Output is correct |
40 |
Correct |
25 ms |
1740 KB |
Output is correct |
41 |
Correct |
24 ms |
1644 KB |
Output is correct |
42 |
Correct |
23 ms |
1624 KB |
Output is correct |
43 |
Correct |
24 ms |
1884 KB |
Output is correct |
44 |
Correct |
23 ms |
1868 KB |
Output is correct |
45 |
Correct |
26 ms |
1992 KB |
Output is correct |
46 |
Correct |
23 ms |
1660 KB |
Output is correct |
47 |
Correct |
23 ms |
1640 KB |
Output is correct |
48 |
Correct |
23 ms |
1740 KB |
Output is correct |
49 |
Correct |
21 ms |
1536 KB |
Output is correct |
50 |
Correct |
23 ms |
1640 KB |
Output is correct |
51 |
Correct |
0 ms |
332 KB |
Output is correct |
52 |
Correct |
28 ms |
1956 KB |
Output is correct |
53 |
Correct |
27 ms |
1876 KB |
Output is correct |
54 |
Correct |
32 ms |
1988 KB |
Output is correct |
55 |
Correct |
41 ms |
2140 KB |
Output is correct |
56 |
Correct |
29 ms |
1988 KB |
Output is correct |
57 |
Correct |
38 ms |
2252 KB |
Output is correct |
58 |
Correct |
34 ms |
2036 KB |
Output is correct |
59 |
Correct |
35 ms |
2116 KB |
Output is correct |
60 |
Correct |
1 ms |
332 KB |
Output is correct |
61 |
Correct |
34 ms |
2112 KB |
Output is correct |
62 |
Correct |
31 ms |
2112 KB |
Output is correct |
63 |
Correct |
33 ms |
2128 KB |
Output is correct |
64 |
Correct |
31 ms |
2136 KB |
Output is correct |
65 |
Correct |
27 ms |
1612 KB |
Output is correct |
66 |
Correct |
28 ms |
1612 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
716 KB |
Output is correct |
2 |
Correct |
2 ms |
796 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
716 KB |
Output is correct |
5 |
Correct |
3 ms |
972 KB |
Output is correct |
6 |
Correct |
2 ms |
844 KB |
Output is correct |
7 |
Correct |
2 ms |
844 KB |
Output is correct |
8 |
Correct |
2 ms |
972 KB |
Output is correct |
9 |
Correct |
2 ms |
972 KB |
Output is correct |
10 |
Correct |
3 ms |
1100 KB |
Output is correct |
11 |
Correct |
4 ms |
1100 KB |
Output is correct |
12 |
Correct |
4 ms |
1100 KB |
Output is correct |
13 |
Correct |
3 ms |
1100 KB |
Output is correct |
14 |
Correct |
4 ms |
1100 KB |
Output is correct |
15 |
Correct |
4 ms |
1152 KB |
Output is correct |
16 |
Correct |
4 ms |
1156 KB |
Output is correct |
17 |
Correct |
3 ms |
1100 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 |
1028 KB |
Output is correct |
21 |
Correct |
6 ms |
1292 KB |
Output is correct |
22 |
Correct |
10 ms |
1404 KB |
Output is correct |
23 |
Correct |
8 ms |
1228 KB |
Output is correct |
24 |
Correct |
8 ms |
1412 KB |
Output is correct |
25 |
Correct |
9 ms |
1420 KB |
Output is correct |
26 |
Correct |
10 ms |
1396 KB |
Output is correct |
27 |
Correct |
9 ms |
1412 KB |
Output is correct |
28 |
Correct |
9 ms |
1404 KB |
Output is correct |
29 |
Correct |
9 ms |
1356 KB |
Output is correct |
30 |
Correct |
8 ms |
1356 KB |
Output is correct |
31 |
Correct |
9 ms |
1356 KB |
Output is correct |
32 |
Correct |
9 ms |
1404 KB |
Output is correct |
33 |
Correct |
9 ms |
1356 KB |
Output is correct |
34 |
Correct |
8 ms |
1396 KB |
Output is correct |
35 |
Correct |
9 ms |
1392 KB |
Output is correct |
36 |
Correct |
9 ms |
1356 KB |
Output is correct |
37 |
Correct |
18 ms |
1612 KB |
Output is correct |
38 |
Correct |
17 ms |
1648 KB |
Output is correct |
39 |
Correct |
22 ms |
1408 KB |
Output is correct |
40 |
Correct |
25 ms |
1740 KB |
Output is correct |
41 |
Correct |
24 ms |
1644 KB |
Output is correct |
42 |
Correct |
23 ms |
1624 KB |
Output is correct |
43 |
Correct |
24 ms |
1884 KB |
Output is correct |
44 |
Correct |
23 ms |
1868 KB |
Output is correct |
45 |
Correct |
26 ms |
1992 KB |
Output is correct |
46 |
Correct |
23 ms |
1660 KB |
Output is correct |
47 |
Correct |
23 ms |
1640 KB |
Output is correct |
48 |
Correct |
23 ms |
1740 KB |
Output is correct |
49 |
Correct |
21 ms |
1536 KB |
Output is correct |
50 |
Correct |
23 ms |
1640 KB |
Output is correct |
51 |
Correct |
0 ms |
332 KB |
Output is correct |
52 |
Correct |
28 ms |
1956 KB |
Output is correct |
53 |
Correct |
27 ms |
1876 KB |
Output is correct |
54 |
Correct |
32 ms |
1988 KB |
Output is correct |
55 |
Correct |
41 ms |
2140 KB |
Output is correct |
56 |
Correct |
29 ms |
1988 KB |
Output is correct |
57 |
Correct |
38 ms |
2252 KB |
Output is correct |
58 |
Correct |
34 ms |
2036 KB |
Output is correct |
59 |
Correct |
35 ms |
2116 KB |
Output is correct |
60 |
Correct |
1 ms |
332 KB |
Output is correct |
61 |
Correct |
34 ms |
2112 KB |
Output is correct |
62 |
Correct |
31 ms |
2112 KB |
Output is correct |
63 |
Correct |
33 ms |
2128 KB |
Output is correct |
64 |
Correct |
31 ms |
2136 KB |
Output is correct |
65 |
Correct |
27 ms |
1612 KB |
Output is correct |
66 |
Correct |
28 ms |
1612 KB |
Output is correct |
67 |
Correct |
39 ms |
2140 KB |
Output is correct |
68 |
Correct |
4 ms |
332 KB |
Output is correct |
69 |
Correct |
52 ms |
2764 KB |
Output is correct |
70 |
Correct |
50 ms |
2368 KB |
Output is correct |
71 |
Correct |
58 ms |
2260 KB |
Output is correct |
72 |
Correct |
43 ms |
1536 KB |
Output is correct |
73 |
Correct |
43 ms |
1612 KB |
Output is correct |
74 |
Correct |
53 ms |
2876 KB |
Output is correct |
75 |
Correct |
51 ms |
2636 KB |
Output is correct |
76 |
Correct |
52 ms |
2780 KB |
Output is correct |
77 |
Correct |
53 ms |
2876 KB |
Output is correct |