#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,unroll-loops")
#define ll long long
#define int ll
#define ull unsigned ll
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define chkmin(a,b) (a=min(a,b))
#define chkmax(a,b) (a=max(a,b))
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
//#define inf 1010000000
#define inf 4000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#ifdef i_am_noob
#define bug(...) cerr << "#" << __LINE__ << ' ' << #__VA_ARGS__ << "- ", _do(__VA_ARGS__)
template<typename T> void _do(T && x) {cerr << x << endl;}
template<typename T, typename ...S> void _do(T && x, S&&...y) {cerr << x << ", "; _do(y...);}
#else
#define bug(...) 777771449
#endif
const int mod=1000000007;
const int maxn=505,maxm=18,maxk=7777714;
//i_am_noob
int n,a[maxn],sum;
bitset<maxn*maxn> bs[maxn];
bool vis[maxn];
void orzck(){
cin >> n;
rep(n) cin >> a[i];
sum=accumulate(a,a+n,0ll);
bitset<maxn*maxn> b;
b[0]=1;
rep(n) b|=b<<a[i];
if((sum&1)||!b[sum/2]){
cout << "0\n";
return;
}
rep(n) if((a[0]+a[i])&1){
cout << "0\n";
return;
}
b.set();
rep(n) if(!vis[a[i]]){
bs[i][0]=1;
rep1(j,n) if(i!=j) bs[i]|=bs[i]<<a[j];
bs[i]<<=a[i]/2;
vis[a[i]]=1;
b&=bs[i];
}
vector<int> res;
rep2(i,1,sum+1) if((i+a[0])%2==0){
if(b[(sum+i)/2]) res.pb(i);
}
cout << sz(res) << "\n";
for(auto i: res) cout << i << ' ';
cout << "\n";
}
signed main(){
ios_base::sync_with_stdio(0),cin.tie(0);
orzck();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
596 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
724 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
724 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
596 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
724 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
724 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
3 ms |
724 KB |
Output is correct |
12 |
Correct |
3 ms |
724 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
724 KB |
Output is correct |
15 |
Correct |
3 ms |
596 KB |
Output is correct |
16 |
Correct |
3 ms |
724 KB |
Output is correct |
17 |
Correct |
2 ms |
596 KB |
Output is correct |
18 |
Correct |
3 ms |
708 KB |
Output is correct |
19 |
Correct |
2 ms |
596 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
596 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
724 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
724 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
3 ms |
724 KB |
Output is correct |
12 |
Correct |
3 ms |
724 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
724 KB |
Output is correct |
15 |
Correct |
3 ms |
596 KB |
Output is correct |
16 |
Correct |
3 ms |
724 KB |
Output is correct |
17 |
Correct |
2 ms |
596 KB |
Output is correct |
18 |
Correct |
3 ms |
708 KB |
Output is correct |
19 |
Correct |
2 ms |
596 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
15 ms |
1568 KB |
Output is correct |
22 |
Correct |
20 ms |
1628 KB |
Output is correct |
23 |
Correct |
11 ms |
1384 KB |
Output is correct |
24 |
Correct |
35 ms |
1724 KB |
Output is correct |
25 |
Correct |
5 ms |
596 KB |
Output is correct |
26 |
Correct |
8 ms |
596 KB |
Output is correct |
27 |
Correct |
6 ms |
596 KB |
Output is correct |
28 |
Correct |
4 ms |
468 KB |
Output is correct |
29 |
Correct |
4 ms |
468 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
17 ms |
1236 KB |
Output is correct |
32 |
Correct |
29 ms |
1868 KB |
Output is correct |
33 |
Correct |
2 ms |
340 KB |
Output is correct |
34 |
Correct |
1 ms |
340 KB |
Output is correct |
35 |
Correct |
3 ms |
468 KB |
Output is correct |
36 |
Correct |
35 ms |
2084 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
596 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
724 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
724 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
3 ms |
724 KB |
Output is correct |
12 |
Correct |
3 ms |
724 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
724 KB |
Output is correct |
15 |
Correct |
3 ms |
596 KB |
Output is correct |
16 |
Correct |
3 ms |
724 KB |
Output is correct |
17 |
Correct |
2 ms |
596 KB |
Output is correct |
18 |
Correct |
3 ms |
708 KB |
Output is correct |
19 |
Correct |
2 ms |
596 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
15 ms |
1568 KB |
Output is correct |
22 |
Correct |
20 ms |
1628 KB |
Output is correct |
23 |
Correct |
11 ms |
1384 KB |
Output is correct |
24 |
Correct |
35 ms |
1724 KB |
Output is correct |
25 |
Correct |
5 ms |
596 KB |
Output is correct |
26 |
Correct |
8 ms |
596 KB |
Output is correct |
27 |
Correct |
6 ms |
596 KB |
Output is correct |
28 |
Correct |
4 ms |
468 KB |
Output is correct |
29 |
Correct |
4 ms |
468 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
17 ms |
1236 KB |
Output is correct |
32 |
Correct |
29 ms |
1868 KB |
Output is correct |
33 |
Correct |
2 ms |
340 KB |
Output is correct |
34 |
Correct |
1 ms |
340 KB |
Output is correct |
35 |
Correct |
3 ms |
468 KB |
Output is correct |
36 |
Correct |
35 ms |
2084 KB |
Output is correct |
37 |
Correct |
80 ms |
2248 KB |
Output is correct |
38 |
Correct |
68 ms |
2320 KB |
Output is correct |
39 |
Correct |
4 ms |
340 KB |
Output is correct |
40 |
Correct |
245 ms |
5192 KB |
Output is correct |
41 |
Correct |
3 ms |
340 KB |
Output is correct |
42 |
Correct |
178 ms |
4348 KB |
Output is correct |
43 |
Correct |
51 ms |
1700 KB |
Output is correct |
44 |
Correct |
46 ms |
1656 KB |
Output is correct |
45 |
Correct |
48 ms |
1616 KB |
Output is correct |
46 |
Correct |
234 ms |
4780 KB |
Output is correct |
47 |
Correct |
226 ms |
4268 KB |
Output is correct |
48 |
Correct |
12 ms |
984 KB |
Output is correct |
49 |
Correct |
7 ms |
636 KB |
Output is correct |
50 |
Correct |
236 ms |
4864 KB |
Output is correct |
51 |
Correct |
2 ms |
340 KB |
Output is correct |
52 |
Correct |
23 ms |
1240 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
596 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
724 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
724 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
3 ms |
724 KB |
Output is correct |
12 |
Correct |
3 ms |
724 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
724 KB |
Output is correct |
15 |
Correct |
3 ms |
596 KB |
Output is correct |
16 |
Correct |
3 ms |
724 KB |
Output is correct |
17 |
Correct |
2 ms |
596 KB |
Output is correct |
18 |
Correct |
3 ms |
708 KB |
Output is correct |
19 |
Correct |
2 ms |
596 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
15 ms |
1568 KB |
Output is correct |
22 |
Correct |
20 ms |
1628 KB |
Output is correct |
23 |
Correct |
11 ms |
1384 KB |
Output is correct |
24 |
Correct |
35 ms |
1724 KB |
Output is correct |
25 |
Correct |
5 ms |
596 KB |
Output is correct |
26 |
Correct |
8 ms |
596 KB |
Output is correct |
27 |
Correct |
6 ms |
596 KB |
Output is correct |
28 |
Correct |
4 ms |
468 KB |
Output is correct |
29 |
Correct |
4 ms |
468 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
17 ms |
1236 KB |
Output is correct |
32 |
Correct |
29 ms |
1868 KB |
Output is correct |
33 |
Correct |
2 ms |
340 KB |
Output is correct |
34 |
Correct |
1 ms |
340 KB |
Output is correct |
35 |
Correct |
3 ms |
468 KB |
Output is correct |
36 |
Correct |
35 ms |
2084 KB |
Output is correct |
37 |
Correct |
80 ms |
2248 KB |
Output is correct |
38 |
Correct |
68 ms |
2320 KB |
Output is correct |
39 |
Correct |
4 ms |
340 KB |
Output is correct |
40 |
Correct |
245 ms |
5192 KB |
Output is correct |
41 |
Correct |
3 ms |
340 KB |
Output is correct |
42 |
Correct |
178 ms |
4348 KB |
Output is correct |
43 |
Correct |
51 ms |
1700 KB |
Output is correct |
44 |
Correct |
46 ms |
1656 KB |
Output is correct |
45 |
Correct |
48 ms |
1616 KB |
Output is correct |
46 |
Correct |
234 ms |
4780 KB |
Output is correct |
47 |
Correct |
226 ms |
4268 KB |
Output is correct |
48 |
Correct |
12 ms |
984 KB |
Output is correct |
49 |
Correct |
7 ms |
636 KB |
Output is correct |
50 |
Correct |
236 ms |
4864 KB |
Output is correct |
51 |
Correct |
2 ms |
340 KB |
Output is correct |
52 |
Correct |
23 ms |
1240 KB |
Output is correct |
53 |
Correct |
224 ms |
4652 KB |
Output is correct |
54 |
Correct |
280 ms |
4936 KB |
Output is correct |
55 |
Correct |
41 ms |
1740 KB |
Output is correct |
56 |
Correct |
262 ms |
5128 KB |
Output is correct |
57 |
Correct |
42 ms |
1720 KB |
Output is correct |
58 |
Correct |
420 ms |
6660 KB |
Output is correct |
59 |
Correct |
231 ms |
4332 KB |
Output is correct |
60 |
Correct |
3 ms |
340 KB |
Output is correct |
61 |
Correct |
227 ms |
4368 KB |
Output is correct |
62 |
Correct |
108 ms |
2740 KB |
Output is correct |
63 |
Correct |
59 ms |
2012 KB |
Output is correct |
64 |
Correct |
59 ms |
1984 KB |
Output is correct |
65 |
Correct |
18 ms |
596 KB |
Output is correct |
66 |
Correct |
71 ms |
1656 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
596 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
724 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
724 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
3 ms |
724 KB |
Output is correct |
12 |
Correct |
3 ms |
724 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
724 KB |
Output is correct |
15 |
Correct |
3 ms |
596 KB |
Output is correct |
16 |
Correct |
3 ms |
724 KB |
Output is correct |
17 |
Correct |
2 ms |
596 KB |
Output is correct |
18 |
Correct |
3 ms |
708 KB |
Output is correct |
19 |
Correct |
2 ms |
596 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
15 ms |
1568 KB |
Output is correct |
22 |
Correct |
20 ms |
1628 KB |
Output is correct |
23 |
Correct |
11 ms |
1384 KB |
Output is correct |
24 |
Correct |
35 ms |
1724 KB |
Output is correct |
25 |
Correct |
5 ms |
596 KB |
Output is correct |
26 |
Correct |
8 ms |
596 KB |
Output is correct |
27 |
Correct |
6 ms |
596 KB |
Output is correct |
28 |
Correct |
4 ms |
468 KB |
Output is correct |
29 |
Correct |
4 ms |
468 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
17 ms |
1236 KB |
Output is correct |
32 |
Correct |
29 ms |
1868 KB |
Output is correct |
33 |
Correct |
2 ms |
340 KB |
Output is correct |
34 |
Correct |
1 ms |
340 KB |
Output is correct |
35 |
Correct |
3 ms |
468 KB |
Output is correct |
36 |
Correct |
35 ms |
2084 KB |
Output is correct |
37 |
Correct |
80 ms |
2248 KB |
Output is correct |
38 |
Correct |
68 ms |
2320 KB |
Output is correct |
39 |
Correct |
4 ms |
340 KB |
Output is correct |
40 |
Correct |
245 ms |
5192 KB |
Output is correct |
41 |
Correct |
3 ms |
340 KB |
Output is correct |
42 |
Correct |
178 ms |
4348 KB |
Output is correct |
43 |
Correct |
51 ms |
1700 KB |
Output is correct |
44 |
Correct |
46 ms |
1656 KB |
Output is correct |
45 |
Correct |
48 ms |
1616 KB |
Output is correct |
46 |
Correct |
234 ms |
4780 KB |
Output is correct |
47 |
Correct |
226 ms |
4268 KB |
Output is correct |
48 |
Correct |
12 ms |
984 KB |
Output is correct |
49 |
Correct |
7 ms |
636 KB |
Output is correct |
50 |
Correct |
236 ms |
4864 KB |
Output is correct |
51 |
Correct |
2 ms |
340 KB |
Output is correct |
52 |
Correct |
23 ms |
1240 KB |
Output is correct |
53 |
Correct |
224 ms |
4652 KB |
Output is correct |
54 |
Correct |
280 ms |
4936 KB |
Output is correct |
55 |
Correct |
41 ms |
1740 KB |
Output is correct |
56 |
Correct |
262 ms |
5128 KB |
Output is correct |
57 |
Correct |
42 ms |
1720 KB |
Output is correct |
58 |
Correct |
420 ms |
6660 KB |
Output is correct |
59 |
Correct |
231 ms |
4332 KB |
Output is correct |
60 |
Correct |
3 ms |
340 KB |
Output is correct |
61 |
Correct |
227 ms |
4368 KB |
Output is correct |
62 |
Correct |
108 ms |
2740 KB |
Output is correct |
63 |
Correct |
59 ms |
2012 KB |
Output is correct |
64 |
Correct |
59 ms |
1984 KB |
Output is correct |
65 |
Correct |
18 ms |
596 KB |
Output is correct |
66 |
Correct |
71 ms |
1656 KB |
Output is correct |
67 |
Correct |
518 ms |
8040 KB |
Output is correct |
68 |
Correct |
3 ms |
340 KB |
Output is correct |
69 |
Correct |
95 ms |
2796 KB |
Output is correct |
70 |
Correct |
804 ms |
9540 KB |
Output is correct |
71 |
Correct |
851 ms |
9540 KB |
Output is correct |
72 |
Correct |
4 ms |
340 KB |
Output is correct |
73 |
Correct |
4 ms |
420 KB |
Output is correct |
74 |
Correct |
197 ms |
3868 KB |
Output is correct |
75 |
Correct |
449 ms |
6496 KB |
Output is correct |
76 |
Correct |
65 ms |
2376 KB |
Output is correct |
77 |
Correct |
99 ms |
2944 KB |
Output is correct |