#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];
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;
}
rep(n){
bs[i][0]=1;
rep1(j,n) if(i!=j) bs[i]|=bs[i]<<a[j];
bs[i]<<=a[i]/2;
}
b.set();
rep(n) 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;
}
# |
Verdict |
Execution time |
Memory |
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 |
1 ms |
468 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 |
596 KB |
Output is correct |
8 |
Correct |
1 ms |
724 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
1 ms |
468 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 |
596 KB |
Output is correct |
8 |
Correct |
1 ms |
724 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
7 ms |
1236 KB |
Output is correct |
11 |
Correct |
7 ms |
1336 KB |
Output is correct |
12 |
Correct |
7 ms |
1236 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
7 ms |
1176 KB |
Output is correct |
15 |
Correct |
10 ms |
1236 KB |
Output is correct |
16 |
Correct |
7 ms |
1236 KB |
Output is correct |
17 |
Correct |
3 ms |
980 KB |
Output is correct |
18 |
Correct |
5 ms |
1120 KB |
Output is correct |
19 |
Correct |
6 ms |
1108 KB |
Output is correct |
20 |
Correct |
8 ms |
1236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
1 ms |
468 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 |
596 KB |
Output is correct |
8 |
Correct |
1 ms |
724 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
7 ms |
1236 KB |
Output is correct |
11 |
Correct |
7 ms |
1336 KB |
Output is correct |
12 |
Correct |
7 ms |
1236 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
7 ms |
1176 KB |
Output is correct |
15 |
Correct |
10 ms |
1236 KB |
Output is correct |
16 |
Correct |
7 ms |
1236 KB |
Output is correct |
17 |
Correct |
3 ms |
980 KB |
Output is correct |
18 |
Correct |
5 ms |
1120 KB |
Output is correct |
19 |
Correct |
6 ms |
1108 KB |
Output is correct |
20 |
Correct |
8 ms |
1236 KB |
Output is correct |
21 |
Correct |
32 ms |
2548 KB |
Output is correct |
22 |
Correct |
37 ms |
2744 KB |
Output is correct |
23 |
Correct |
18 ms |
1984 KB |
Output is correct |
24 |
Correct |
80 ms |
3276 KB |
Output is correct |
25 |
Correct |
64 ms |
3352 KB |
Output is correct |
26 |
Correct |
90 ms |
3532 KB |
Output is correct |
27 |
Correct |
66 ms |
3480 KB |
Output is correct |
28 |
Correct |
70 ms |
3544 KB |
Output is correct |
29 |
Correct |
84 ms |
3572 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
69 ms |
3600 KB |
Output is correct |
32 |
Correct |
69 ms |
3544 KB |
Output is correct |
33 |
Correct |
64 ms |
3416 KB |
Output is correct |
34 |
Correct |
70 ms |
3412 KB |
Output is correct |
35 |
Correct |
73 ms |
3524 KB |
Output is correct |
36 |
Correct |
69 ms |
3532 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
1 ms |
468 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 |
596 KB |
Output is correct |
8 |
Correct |
1 ms |
724 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
7 ms |
1236 KB |
Output is correct |
11 |
Correct |
7 ms |
1336 KB |
Output is correct |
12 |
Correct |
7 ms |
1236 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
7 ms |
1176 KB |
Output is correct |
15 |
Correct |
10 ms |
1236 KB |
Output is correct |
16 |
Correct |
7 ms |
1236 KB |
Output is correct |
17 |
Correct |
3 ms |
980 KB |
Output is correct |
18 |
Correct |
5 ms |
1120 KB |
Output is correct |
19 |
Correct |
6 ms |
1108 KB |
Output is correct |
20 |
Correct |
8 ms |
1236 KB |
Output is correct |
21 |
Correct |
32 ms |
2548 KB |
Output is correct |
22 |
Correct |
37 ms |
2744 KB |
Output is correct |
23 |
Correct |
18 ms |
1984 KB |
Output is correct |
24 |
Correct |
80 ms |
3276 KB |
Output is correct |
25 |
Correct |
64 ms |
3352 KB |
Output is correct |
26 |
Correct |
90 ms |
3532 KB |
Output is correct |
27 |
Correct |
66 ms |
3480 KB |
Output is correct |
28 |
Correct |
70 ms |
3544 KB |
Output is correct |
29 |
Correct |
84 ms |
3572 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
69 ms |
3600 KB |
Output is correct |
32 |
Correct |
69 ms |
3544 KB |
Output is correct |
33 |
Correct |
64 ms |
3416 KB |
Output is correct |
34 |
Correct |
70 ms |
3412 KB |
Output is correct |
35 |
Correct |
73 ms |
3524 KB |
Output is correct |
36 |
Correct |
69 ms |
3532 KB |
Output is correct |
37 |
Correct |
273 ms |
6920 KB |
Output is correct |
38 |
Correct |
266 ms |
6860 KB |
Output is correct |
39 |
Correct |
438 ms |
8100 KB |
Output is correct |
40 |
Correct |
502 ms |
9172 KB |
Output is correct |
41 |
Correct |
494 ms |
8768 KB |
Output is correct |
42 |
Correct |
397 ms |
8520 KB |
Output is correct |
43 |
Correct |
413 ms |
8428 KB |
Output is correct |
44 |
Correct |
409 ms |
8536 KB |
Output is correct |
45 |
Correct |
498 ms |
8668 KB |
Output is correct |
46 |
Correct |
482 ms |
8728 KB |
Output is correct |
47 |
Correct |
414 ms |
8536 KB |
Output is correct |
48 |
Correct |
430 ms |
8608 KB |
Output is correct |
49 |
Correct |
422 ms |
8272 KB |
Output is correct |
50 |
Correct |
479 ms |
8488 KB |
Output is correct |
51 |
Correct |
2 ms |
340 KB |
Output is correct |
52 |
Correct |
497 ms |
9384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
1 ms |
468 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 |
596 KB |
Output is correct |
8 |
Correct |
1 ms |
724 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
7 ms |
1236 KB |
Output is correct |
11 |
Correct |
7 ms |
1336 KB |
Output is correct |
12 |
Correct |
7 ms |
1236 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
7 ms |
1176 KB |
Output is correct |
15 |
Correct |
10 ms |
1236 KB |
Output is correct |
16 |
Correct |
7 ms |
1236 KB |
Output is correct |
17 |
Correct |
3 ms |
980 KB |
Output is correct |
18 |
Correct |
5 ms |
1120 KB |
Output is correct |
19 |
Correct |
6 ms |
1108 KB |
Output is correct |
20 |
Correct |
8 ms |
1236 KB |
Output is correct |
21 |
Correct |
32 ms |
2548 KB |
Output is correct |
22 |
Correct |
37 ms |
2744 KB |
Output is correct |
23 |
Correct |
18 ms |
1984 KB |
Output is correct |
24 |
Correct |
80 ms |
3276 KB |
Output is correct |
25 |
Correct |
64 ms |
3352 KB |
Output is correct |
26 |
Correct |
90 ms |
3532 KB |
Output is correct |
27 |
Correct |
66 ms |
3480 KB |
Output is correct |
28 |
Correct |
70 ms |
3544 KB |
Output is correct |
29 |
Correct |
84 ms |
3572 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
69 ms |
3600 KB |
Output is correct |
32 |
Correct |
69 ms |
3544 KB |
Output is correct |
33 |
Correct |
64 ms |
3416 KB |
Output is correct |
34 |
Correct |
70 ms |
3412 KB |
Output is correct |
35 |
Correct |
73 ms |
3524 KB |
Output is correct |
36 |
Correct |
69 ms |
3532 KB |
Output is correct |
37 |
Correct |
273 ms |
6920 KB |
Output is correct |
38 |
Correct |
266 ms |
6860 KB |
Output is correct |
39 |
Correct |
438 ms |
8100 KB |
Output is correct |
40 |
Correct |
502 ms |
9172 KB |
Output is correct |
41 |
Correct |
494 ms |
8768 KB |
Output is correct |
42 |
Correct |
397 ms |
8520 KB |
Output is correct |
43 |
Correct |
413 ms |
8428 KB |
Output is correct |
44 |
Correct |
409 ms |
8536 KB |
Output is correct |
45 |
Correct |
498 ms |
8668 KB |
Output is correct |
46 |
Correct |
482 ms |
8728 KB |
Output is correct |
47 |
Correct |
414 ms |
8536 KB |
Output is correct |
48 |
Correct |
430 ms |
8608 KB |
Output is correct |
49 |
Correct |
422 ms |
8272 KB |
Output is correct |
50 |
Correct |
479 ms |
8488 KB |
Output is correct |
51 |
Correct |
2 ms |
340 KB |
Output is correct |
52 |
Correct |
497 ms |
9384 KB |
Output is correct |
53 |
Correct |
606 ms |
10152 KB |
Output is correct |
54 |
Correct |
835 ms |
11896 KB |
Output is correct |
55 |
Correct |
830 ms |
12112 KB |
Output is correct |
56 |
Correct |
621 ms |
10460 KB |
Output is correct |
57 |
Correct |
817 ms |
12224 KB |
Output is correct |
58 |
Correct |
855 ms |
11872 KB |
Output is correct |
59 |
Correct |
804 ms |
12044 KB |
Output is correct |
60 |
Correct |
3 ms |
340 KB |
Output is correct |
61 |
Correct |
820 ms |
12088 KB |
Output is correct |
62 |
Correct |
723 ms |
11072 KB |
Output is correct |
63 |
Correct |
730 ms |
11084 KB |
Output is correct |
64 |
Correct |
651 ms |
11116 KB |
Output is correct |
65 |
Correct |
679 ms |
10264 KB |
Output is correct |
66 |
Correct |
629 ms |
10144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
1 ms |
468 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 |
596 KB |
Output is correct |
8 |
Correct |
1 ms |
724 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
7 ms |
1236 KB |
Output is correct |
11 |
Correct |
7 ms |
1336 KB |
Output is correct |
12 |
Correct |
7 ms |
1236 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
7 ms |
1176 KB |
Output is correct |
15 |
Correct |
10 ms |
1236 KB |
Output is correct |
16 |
Correct |
7 ms |
1236 KB |
Output is correct |
17 |
Correct |
3 ms |
980 KB |
Output is correct |
18 |
Correct |
5 ms |
1120 KB |
Output is correct |
19 |
Correct |
6 ms |
1108 KB |
Output is correct |
20 |
Correct |
8 ms |
1236 KB |
Output is correct |
21 |
Correct |
32 ms |
2548 KB |
Output is correct |
22 |
Correct |
37 ms |
2744 KB |
Output is correct |
23 |
Correct |
18 ms |
1984 KB |
Output is correct |
24 |
Correct |
80 ms |
3276 KB |
Output is correct |
25 |
Correct |
64 ms |
3352 KB |
Output is correct |
26 |
Correct |
90 ms |
3532 KB |
Output is correct |
27 |
Correct |
66 ms |
3480 KB |
Output is correct |
28 |
Correct |
70 ms |
3544 KB |
Output is correct |
29 |
Correct |
84 ms |
3572 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
69 ms |
3600 KB |
Output is correct |
32 |
Correct |
69 ms |
3544 KB |
Output is correct |
33 |
Correct |
64 ms |
3416 KB |
Output is correct |
34 |
Correct |
70 ms |
3412 KB |
Output is correct |
35 |
Correct |
73 ms |
3524 KB |
Output is correct |
36 |
Correct |
69 ms |
3532 KB |
Output is correct |
37 |
Correct |
273 ms |
6920 KB |
Output is correct |
38 |
Correct |
266 ms |
6860 KB |
Output is correct |
39 |
Correct |
438 ms |
8100 KB |
Output is correct |
40 |
Correct |
502 ms |
9172 KB |
Output is correct |
41 |
Correct |
494 ms |
8768 KB |
Output is correct |
42 |
Correct |
397 ms |
8520 KB |
Output is correct |
43 |
Correct |
413 ms |
8428 KB |
Output is correct |
44 |
Correct |
409 ms |
8536 KB |
Output is correct |
45 |
Correct |
498 ms |
8668 KB |
Output is correct |
46 |
Correct |
482 ms |
8728 KB |
Output is correct |
47 |
Correct |
414 ms |
8536 KB |
Output is correct |
48 |
Correct |
430 ms |
8608 KB |
Output is correct |
49 |
Correct |
422 ms |
8272 KB |
Output is correct |
50 |
Correct |
479 ms |
8488 KB |
Output is correct |
51 |
Correct |
2 ms |
340 KB |
Output is correct |
52 |
Correct |
497 ms |
9384 KB |
Output is correct |
53 |
Correct |
606 ms |
10152 KB |
Output is correct |
54 |
Correct |
835 ms |
11896 KB |
Output is correct |
55 |
Correct |
830 ms |
12112 KB |
Output is correct |
56 |
Correct |
621 ms |
10460 KB |
Output is correct |
57 |
Correct |
817 ms |
12224 KB |
Output is correct |
58 |
Correct |
855 ms |
11872 KB |
Output is correct |
59 |
Correct |
804 ms |
12044 KB |
Output is correct |
60 |
Correct |
3 ms |
340 KB |
Output is correct |
61 |
Correct |
820 ms |
12088 KB |
Output is correct |
62 |
Correct |
723 ms |
11072 KB |
Output is correct |
63 |
Correct |
730 ms |
11084 KB |
Output is correct |
64 |
Correct |
651 ms |
11116 KB |
Output is correct |
65 |
Correct |
679 ms |
10264 KB |
Output is correct |
66 |
Correct |
629 ms |
10144 KB |
Output is correct |
67 |
Execution timed out |
1081 ms |
12708 KB |
Time limit exceeded |
68 |
Halted |
0 ms |
0 KB |
- |