#include<bits/stdc++.h>
using namespace std;
const int MAXN=512;
int n,a[MAXN],sum;
struct node
{
vector<int>vals;
bitset<MAXN*MAXN>possible;
};
node tree[4*MAXN];
bitset<MAXN*MAXN>without[MAXN];
void update(int l,int r,int idx,int ql,int qr,int val)
{
if(l>qr)return;
if(r<ql)return;
if(l>=ql&&r<=qr)
{
tree[idx].vals.push_back(val);
return;
}
int mid=(l+r)/2;
update(l,mid,idx*2,ql,qr,val);
update(mid+1,r,idx*2+1,ql,qr,val);
}
void build(int l,int r,int idx)
{
tree[idx].possible[0]=1;
for(auto xd:tree[idx].vals)
{
tree[idx].possible=tree[idx].possible|(tree[idx].possible<<xd);
}
if(l==r)
{
without[l]=tree[idx].possible;
return;
}
int mid=(l+r)/2;
tree[idx*2].possible=tree[idx].possible;
tree[idx*2+1].possible=tree[idx].possible;
build(l,mid,idx*2);
build(mid+1,r,idx*2+1);
}
int main()
{
cin>>n;
for(int i=1;i<=n;i++){cin>>a[i];sum+=a[i];}
if(sum%2==1)
{
cout<<"0\n";
return 0;
}
for(int i=1;i<=n;i++)
{
update(1,n+1,1,1,i-1,a[i]);
update(1,n+1,1,i+1,n+1,a[i]);
}
build(1,n+1,1);
if(without[n+1][sum/2]==0)
{
cout<<"0\n";
return 0;
}
//cout<<"?\n";
vector<int>ans;
for(int cand=1;cand<=sum;cand++)
{
bool ok=1;
for(int i=1;i<=n;i++)
{
int sum1=sum+cand-a[i];
if(sum1%2!=0)
{
ok=0;break;
}
if(without[i][sum1/2]==0)
{
ok=0;break;
}
}
if(ok)ans.push_back(cand);
}
cout<<ans.size()<<endl;
for(auto xd:ans)
{
cout<<xd<<" ";
}
cout<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
66396 KB |
Output is correct |
2 |
Correct |
31 ms |
66500 KB |
Output is correct |
3 |
Correct |
30 ms |
66232 KB |
Output is correct |
4 |
Correct |
32 ms |
66372 KB |
Output is correct |
5 |
Correct |
32 ms |
66696 KB |
Output is correct |
6 |
Correct |
32 ms |
66504 KB |
Output is correct |
7 |
Correct |
30 ms |
66372 KB |
Output is correct |
8 |
Correct |
32 ms |
66628 KB |
Output is correct |
9 |
Correct |
35 ms |
66576 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
66396 KB |
Output is correct |
2 |
Correct |
31 ms |
66500 KB |
Output is correct |
3 |
Correct |
30 ms |
66232 KB |
Output is correct |
4 |
Correct |
32 ms |
66372 KB |
Output is correct |
5 |
Correct |
32 ms |
66696 KB |
Output is correct |
6 |
Correct |
32 ms |
66504 KB |
Output is correct |
7 |
Correct |
30 ms |
66372 KB |
Output is correct |
8 |
Correct |
32 ms |
66628 KB |
Output is correct |
9 |
Correct |
35 ms |
66576 KB |
Output is correct |
10 |
Correct |
32 ms |
67324 KB |
Output is correct |
11 |
Correct |
32 ms |
67268 KB |
Output is correct |
12 |
Correct |
33 ms |
67376 KB |
Output is correct |
13 |
Correct |
33 ms |
67168 KB |
Output is correct |
14 |
Correct |
35 ms |
67256 KB |
Output is correct |
15 |
Correct |
32 ms |
67228 KB |
Output is correct |
16 |
Correct |
33 ms |
67404 KB |
Output is correct |
17 |
Correct |
33 ms |
66928 KB |
Output is correct |
18 |
Correct |
31 ms |
67184 KB |
Output is correct |
19 |
Correct |
35 ms |
67148 KB |
Output is correct |
20 |
Correct |
33 ms |
67256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
66396 KB |
Output is correct |
2 |
Correct |
31 ms |
66500 KB |
Output is correct |
3 |
Correct |
30 ms |
66232 KB |
Output is correct |
4 |
Correct |
32 ms |
66372 KB |
Output is correct |
5 |
Correct |
32 ms |
66696 KB |
Output is correct |
6 |
Correct |
32 ms |
66504 KB |
Output is correct |
7 |
Correct |
30 ms |
66372 KB |
Output is correct |
8 |
Correct |
32 ms |
66628 KB |
Output is correct |
9 |
Correct |
35 ms |
66576 KB |
Output is correct |
10 |
Correct |
32 ms |
67324 KB |
Output is correct |
11 |
Correct |
32 ms |
67268 KB |
Output is correct |
12 |
Correct |
33 ms |
67376 KB |
Output is correct |
13 |
Correct |
33 ms |
67168 KB |
Output is correct |
14 |
Correct |
35 ms |
67256 KB |
Output is correct |
15 |
Correct |
32 ms |
67228 KB |
Output is correct |
16 |
Correct |
33 ms |
67404 KB |
Output is correct |
17 |
Correct |
33 ms |
66928 KB |
Output is correct |
18 |
Correct |
31 ms |
67184 KB |
Output is correct |
19 |
Correct |
35 ms |
67148 KB |
Output is correct |
20 |
Correct |
33 ms |
67256 KB |
Output is correct |
21 |
Correct |
37 ms |
68548 KB |
Output is correct |
22 |
Correct |
38 ms |
68864 KB |
Output is correct |
23 |
Correct |
40 ms |
68032 KB |
Output is correct |
24 |
Correct |
45 ms |
69640 KB |
Output is correct |
25 |
Correct |
42 ms |
69584 KB |
Output is correct |
26 |
Correct |
44 ms |
69740 KB |
Output is correct |
27 |
Correct |
42 ms |
69764 KB |
Output is correct |
28 |
Correct |
42 ms |
69696 KB |
Output is correct |
29 |
Correct |
41 ms |
69688 KB |
Output is correct |
30 |
Correct |
41 ms |
69704 KB |
Output is correct |
31 |
Correct |
44 ms |
69724 KB |
Output is correct |
32 |
Correct |
42 ms |
69672 KB |
Output is correct |
33 |
Correct |
57 ms |
69680 KB |
Output is correct |
34 |
Correct |
50 ms |
69700 KB |
Output is correct |
35 |
Correct |
41 ms |
69656 KB |
Output is correct |
36 |
Correct |
44 ms |
69760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
66396 KB |
Output is correct |
2 |
Correct |
31 ms |
66500 KB |
Output is correct |
3 |
Correct |
30 ms |
66232 KB |
Output is correct |
4 |
Correct |
32 ms |
66372 KB |
Output is correct |
5 |
Correct |
32 ms |
66696 KB |
Output is correct |
6 |
Correct |
32 ms |
66504 KB |
Output is correct |
7 |
Correct |
30 ms |
66372 KB |
Output is correct |
8 |
Correct |
32 ms |
66628 KB |
Output is correct |
9 |
Correct |
35 ms |
66576 KB |
Output is correct |
10 |
Correct |
32 ms |
67324 KB |
Output is correct |
11 |
Correct |
32 ms |
67268 KB |
Output is correct |
12 |
Correct |
33 ms |
67376 KB |
Output is correct |
13 |
Correct |
33 ms |
67168 KB |
Output is correct |
14 |
Correct |
35 ms |
67256 KB |
Output is correct |
15 |
Correct |
32 ms |
67228 KB |
Output is correct |
16 |
Correct |
33 ms |
67404 KB |
Output is correct |
17 |
Correct |
33 ms |
66928 KB |
Output is correct |
18 |
Correct |
31 ms |
67184 KB |
Output is correct |
19 |
Correct |
35 ms |
67148 KB |
Output is correct |
20 |
Correct |
33 ms |
67256 KB |
Output is correct |
21 |
Correct |
37 ms |
68548 KB |
Output is correct |
22 |
Correct |
38 ms |
68864 KB |
Output is correct |
23 |
Correct |
40 ms |
68032 KB |
Output is correct |
24 |
Correct |
45 ms |
69640 KB |
Output is correct |
25 |
Correct |
42 ms |
69584 KB |
Output is correct |
26 |
Correct |
44 ms |
69740 KB |
Output is correct |
27 |
Correct |
42 ms |
69764 KB |
Output is correct |
28 |
Correct |
42 ms |
69696 KB |
Output is correct |
29 |
Correct |
41 ms |
69688 KB |
Output is correct |
30 |
Correct |
41 ms |
69704 KB |
Output is correct |
31 |
Correct |
44 ms |
69724 KB |
Output is correct |
32 |
Correct |
42 ms |
69672 KB |
Output is correct |
33 |
Correct |
57 ms |
69680 KB |
Output is correct |
34 |
Correct |
50 ms |
69700 KB |
Output is correct |
35 |
Correct |
41 ms |
69656 KB |
Output is correct |
36 |
Correct |
44 ms |
69760 KB |
Output is correct |
37 |
Correct |
68 ms |
73244 KB |
Output is correct |
38 |
Correct |
67 ms |
73096 KB |
Output is correct |
39 |
Correct |
73 ms |
74500 KB |
Output is correct |
40 |
Correct |
107 ms |
75464 KB |
Output is correct |
41 |
Correct |
65 ms |
75340 KB |
Output is correct |
42 |
Correct |
90 ms |
74724 KB |
Output is correct |
43 |
Correct |
112 ms |
74788 KB |
Output is correct |
44 |
Correct |
128 ms |
74856 KB |
Output is correct |
45 |
Correct |
118 ms |
75040 KB |
Output is correct |
46 |
Correct |
62 ms |
75352 KB |
Output is correct |
47 |
Correct |
96 ms |
74956 KB |
Output is correct |
48 |
Correct |
108 ms |
74848 KB |
Output is correct |
49 |
Correct |
71 ms |
74628 KB |
Output is correct |
50 |
Correct |
100 ms |
74752 KB |
Output is correct |
51 |
Correct |
32 ms |
65988 KB |
Output is correct |
52 |
Correct |
130 ms |
75776 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
66396 KB |
Output is correct |
2 |
Correct |
31 ms |
66500 KB |
Output is correct |
3 |
Correct |
30 ms |
66232 KB |
Output is correct |
4 |
Correct |
32 ms |
66372 KB |
Output is correct |
5 |
Correct |
32 ms |
66696 KB |
Output is correct |
6 |
Correct |
32 ms |
66504 KB |
Output is correct |
7 |
Correct |
30 ms |
66372 KB |
Output is correct |
8 |
Correct |
32 ms |
66628 KB |
Output is correct |
9 |
Correct |
35 ms |
66576 KB |
Output is correct |
10 |
Correct |
32 ms |
67324 KB |
Output is correct |
11 |
Correct |
32 ms |
67268 KB |
Output is correct |
12 |
Correct |
33 ms |
67376 KB |
Output is correct |
13 |
Correct |
33 ms |
67168 KB |
Output is correct |
14 |
Correct |
35 ms |
67256 KB |
Output is correct |
15 |
Correct |
32 ms |
67228 KB |
Output is correct |
16 |
Correct |
33 ms |
67404 KB |
Output is correct |
17 |
Correct |
33 ms |
66928 KB |
Output is correct |
18 |
Correct |
31 ms |
67184 KB |
Output is correct |
19 |
Correct |
35 ms |
67148 KB |
Output is correct |
20 |
Correct |
33 ms |
67256 KB |
Output is correct |
21 |
Correct |
37 ms |
68548 KB |
Output is correct |
22 |
Correct |
38 ms |
68864 KB |
Output is correct |
23 |
Correct |
40 ms |
68032 KB |
Output is correct |
24 |
Correct |
45 ms |
69640 KB |
Output is correct |
25 |
Correct |
42 ms |
69584 KB |
Output is correct |
26 |
Correct |
44 ms |
69740 KB |
Output is correct |
27 |
Correct |
42 ms |
69764 KB |
Output is correct |
28 |
Correct |
42 ms |
69696 KB |
Output is correct |
29 |
Correct |
41 ms |
69688 KB |
Output is correct |
30 |
Correct |
41 ms |
69704 KB |
Output is correct |
31 |
Correct |
44 ms |
69724 KB |
Output is correct |
32 |
Correct |
42 ms |
69672 KB |
Output is correct |
33 |
Correct |
57 ms |
69680 KB |
Output is correct |
34 |
Correct |
50 ms |
69700 KB |
Output is correct |
35 |
Correct |
41 ms |
69656 KB |
Output is correct |
36 |
Correct |
44 ms |
69760 KB |
Output is correct |
37 |
Correct |
68 ms |
73244 KB |
Output is correct |
38 |
Correct |
67 ms |
73096 KB |
Output is correct |
39 |
Correct |
73 ms |
74500 KB |
Output is correct |
40 |
Correct |
107 ms |
75464 KB |
Output is correct |
41 |
Correct |
65 ms |
75340 KB |
Output is correct |
42 |
Correct |
90 ms |
74724 KB |
Output is correct |
43 |
Correct |
112 ms |
74788 KB |
Output is correct |
44 |
Correct |
128 ms |
74856 KB |
Output is correct |
45 |
Correct |
118 ms |
75040 KB |
Output is correct |
46 |
Correct |
62 ms |
75352 KB |
Output is correct |
47 |
Correct |
96 ms |
74956 KB |
Output is correct |
48 |
Correct |
108 ms |
74848 KB |
Output is correct |
49 |
Correct |
71 ms |
74628 KB |
Output is correct |
50 |
Correct |
100 ms |
74752 KB |
Output is correct |
51 |
Correct |
32 ms |
65988 KB |
Output is correct |
52 |
Correct |
130 ms |
75776 KB |
Output is correct |
53 |
Correct |
134 ms |
76616 KB |
Output is correct |
54 |
Correct |
195 ms |
78388 KB |
Output is correct |
55 |
Correct |
305 ms |
78508 KB |
Output is correct |
56 |
Correct |
161 ms |
76868 KB |
Output is correct |
57 |
Correct |
242 ms |
78668 KB |
Output is correct |
58 |
Correct |
172 ms |
78276 KB |
Output is correct |
59 |
Correct |
195 ms |
78368 KB |
Output is correct |
60 |
Correct |
38 ms |
65992 KB |
Output is correct |
61 |
Correct |
212 ms |
78544 KB |
Output is correct |
62 |
Correct |
201 ms |
77576 KB |
Output is correct |
63 |
Correct |
211 ms |
77536 KB |
Output is correct |
64 |
Correct |
207 ms |
77404 KB |
Output is correct |
65 |
Correct |
76 ms |
76768 KB |
Output is correct |
66 |
Correct |
86 ms |
76720 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
66396 KB |
Output is correct |
2 |
Correct |
31 ms |
66500 KB |
Output is correct |
3 |
Correct |
30 ms |
66232 KB |
Output is correct |
4 |
Correct |
32 ms |
66372 KB |
Output is correct |
5 |
Correct |
32 ms |
66696 KB |
Output is correct |
6 |
Correct |
32 ms |
66504 KB |
Output is correct |
7 |
Correct |
30 ms |
66372 KB |
Output is correct |
8 |
Correct |
32 ms |
66628 KB |
Output is correct |
9 |
Correct |
35 ms |
66576 KB |
Output is correct |
10 |
Correct |
32 ms |
67324 KB |
Output is correct |
11 |
Correct |
32 ms |
67268 KB |
Output is correct |
12 |
Correct |
33 ms |
67376 KB |
Output is correct |
13 |
Correct |
33 ms |
67168 KB |
Output is correct |
14 |
Correct |
35 ms |
67256 KB |
Output is correct |
15 |
Correct |
32 ms |
67228 KB |
Output is correct |
16 |
Correct |
33 ms |
67404 KB |
Output is correct |
17 |
Correct |
33 ms |
66928 KB |
Output is correct |
18 |
Correct |
31 ms |
67184 KB |
Output is correct |
19 |
Correct |
35 ms |
67148 KB |
Output is correct |
20 |
Correct |
33 ms |
67256 KB |
Output is correct |
21 |
Correct |
37 ms |
68548 KB |
Output is correct |
22 |
Correct |
38 ms |
68864 KB |
Output is correct |
23 |
Correct |
40 ms |
68032 KB |
Output is correct |
24 |
Correct |
45 ms |
69640 KB |
Output is correct |
25 |
Correct |
42 ms |
69584 KB |
Output is correct |
26 |
Correct |
44 ms |
69740 KB |
Output is correct |
27 |
Correct |
42 ms |
69764 KB |
Output is correct |
28 |
Correct |
42 ms |
69696 KB |
Output is correct |
29 |
Correct |
41 ms |
69688 KB |
Output is correct |
30 |
Correct |
41 ms |
69704 KB |
Output is correct |
31 |
Correct |
44 ms |
69724 KB |
Output is correct |
32 |
Correct |
42 ms |
69672 KB |
Output is correct |
33 |
Correct |
57 ms |
69680 KB |
Output is correct |
34 |
Correct |
50 ms |
69700 KB |
Output is correct |
35 |
Correct |
41 ms |
69656 KB |
Output is correct |
36 |
Correct |
44 ms |
69760 KB |
Output is correct |
37 |
Correct |
68 ms |
73244 KB |
Output is correct |
38 |
Correct |
67 ms |
73096 KB |
Output is correct |
39 |
Correct |
73 ms |
74500 KB |
Output is correct |
40 |
Correct |
107 ms |
75464 KB |
Output is correct |
41 |
Correct |
65 ms |
75340 KB |
Output is correct |
42 |
Correct |
90 ms |
74724 KB |
Output is correct |
43 |
Correct |
112 ms |
74788 KB |
Output is correct |
44 |
Correct |
128 ms |
74856 KB |
Output is correct |
45 |
Correct |
118 ms |
75040 KB |
Output is correct |
46 |
Correct |
62 ms |
75352 KB |
Output is correct |
47 |
Correct |
96 ms |
74956 KB |
Output is correct |
48 |
Correct |
108 ms |
74848 KB |
Output is correct |
49 |
Correct |
71 ms |
74628 KB |
Output is correct |
50 |
Correct |
100 ms |
74752 KB |
Output is correct |
51 |
Correct |
32 ms |
65988 KB |
Output is correct |
52 |
Correct |
130 ms |
75776 KB |
Output is correct |
53 |
Correct |
134 ms |
76616 KB |
Output is correct |
54 |
Correct |
195 ms |
78388 KB |
Output is correct |
55 |
Correct |
305 ms |
78508 KB |
Output is correct |
56 |
Correct |
161 ms |
76868 KB |
Output is correct |
57 |
Correct |
242 ms |
78668 KB |
Output is correct |
58 |
Correct |
172 ms |
78276 KB |
Output is correct |
59 |
Correct |
195 ms |
78368 KB |
Output is correct |
60 |
Correct |
38 ms |
65992 KB |
Output is correct |
61 |
Correct |
212 ms |
78544 KB |
Output is correct |
62 |
Correct |
201 ms |
77576 KB |
Output is correct |
63 |
Correct |
211 ms |
77536 KB |
Output is correct |
64 |
Correct |
207 ms |
77404 KB |
Output is correct |
65 |
Correct |
76 ms |
76768 KB |
Output is correct |
66 |
Correct |
86 ms |
76720 KB |
Output is correct |
67 |
Correct |
247 ms |
80056 KB |
Output is correct |
68 |
Correct |
97 ms |
82680 KB |
Output is correct |
69 |
Correct |
550 ms |
83888 KB |
Output is correct |
70 |
Correct |
392 ms |
83508 KB |
Output is correct |
71 |
Correct |
377 ms |
83476 KB |
Output is correct |
72 |
Correct |
113 ms |
82668 KB |
Output is correct |
73 |
Correct |
99 ms |
82664 KB |
Output is correct |
74 |
Correct |
592 ms |
83980 KB |
Output is correct |
75 |
Correct |
512 ms |
83612 KB |
Output is correct |
76 |
Correct |
570 ms |
83860 KB |
Output is correct |
77 |
Correct |
610 ms |
84028 KB |
Output is correct |