#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define all(a) a.begin(),a.end()
#define ull unsigned long long
#define endl '\n'
#define y1 yaumru
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define iter vector<int>::iterator
using namespace std;
using namespace __gnu_pbds;
template<class T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class T>
using ordered_multiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rnd1(chrono::steady_clock::now().time_since_epoch().count());
//find_by_order
//order_of_key
const int N=500+1;
const int inf=1e9+1e9;
const int mod=1e9+7;
const ld eps=1e-9;
const int M=122500+1;
bitset<M>dp[N];
int a[N];
main ()
{
ios;
int n;
cin>>n;
for (int i=1;i<=n;++i){
cin>>a[i];
}
int sum=0;
for (int i=1;i<=n;++i){
sum+=a[i];
}
if (sum%2==1){
cout<<0<<endl;
exit(0);
}
for (int i=0;i<=n;++i){
dp[i][0]=1;
for (int j=1;j<=n;++j){
if (j==i)continue;
bitset<M>f=(dp[i]<<a[j]);
dp[i]=(dp[i]|f);
}
}
vector<int>ans;
if (dp[0][sum/2]==0){
cout<<0<<endl;
exit(0);
}
for (int i=1;i<=M;++i){
bool cc=true;
for (int j=1;j<=n;++j){
if ((sum-a[j]+i)%2==1){
cc=false;
break;
}
if ((sum-a[j]+i)%2==0){
if (dp[j][(sum-a[j]+i)/2]==0){
cc=false;
break;
}
}
}
if (cc)ans.pb(i);
}
cout<<(int)ans.size()<<endl;
for (int i=0;i<ans.size();++i){
cout<<ans[i]<<' ';
}
}
Compilation message
bootfall.cpp:41:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main ()
^
bootfall.cpp: In function 'int main()':
bootfall.cpp:87:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0;i<ans.size();++i){
~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
3 ms |
532 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
404 KB |
Output is correct |
5 |
Correct |
3 ms |
552 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
7 |
Correct |
3 ms |
508 KB |
Output is correct |
8 |
Correct |
3 ms |
528 KB |
Output is correct |
9 |
Correct |
3 ms |
524 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
3 ms |
532 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
404 KB |
Output is correct |
5 |
Correct |
3 ms |
552 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
7 |
Correct |
3 ms |
508 KB |
Output is correct |
8 |
Correct |
3 ms |
528 KB |
Output is correct |
9 |
Correct |
3 ms |
524 KB |
Output is correct |
10 |
Correct |
9 ms |
892 KB |
Output is correct |
11 |
Correct |
8 ms |
888 KB |
Output is correct |
12 |
Correct |
8 ms |
888 KB |
Output is correct |
13 |
Correct |
7 ms |
732 KB |
Output is correct |
14 |
Correct |
8 ms |
784 KB |
Output is correct |
15 |
Correct |
8 ms |
864 KB |
Output is correct |
16 |
Correct |
9 ms |
892 KB |
Output is correct |
17 |
Correct |
5 ms |
632 KB |
Output is correct |
18 |
Correct |
7 ms |
736 KB |
Output is correct |
19 |
Correct |
7 ms |
760 KB |
Output is correct |
20 |
Correct |
9 ms |
776 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
3 ms |
532 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
404 KB |
Output is correct |
5 |
Correct |
3 ms |
552 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
7 |
Correct |
3 ms |
508 KB |
Output is correct |
8 |
Correct |
3 ms |
528 KB |
Output is correct |
9 |
Correct |
3 ms |
524 KB |
Output is correct |
10 |
Correct |
9 ms |
892 KB |
Output is correct |
11 |
Correct |
8 ms |
888 KB |
Output is correct |
12 |
Correct |
8 ms |
888 KB |
Output is correct |
13 |
Correct |
7 ms |
732 KB |
Output is correct |
14 |
Correct |
8 ms |
784 KB |
Output is correct |
15 |
Correct |
8 ms |
864 KB |
Output is correct |
16 |
Correct |
9 ms |
892 KB |
Output is correct |
17 |
Correct |
5 ms |
632 KB |
Output is correct |
18 |
Correct |
7 ms |
736 KB |
Output is correct |
19 |
Correct |
7 ms |
760 KB |
Output is correct |
20 |
Correct |
9 ms |
776 KB |
Output is correct |
21 |
Correct |
29 ms |
1424 KB |
Output is correct |
22 |
Correct |
38 ms |
1528 KB |
Output is correct |
23 |
Correct |
19 ms |
1144 KB |
Output is correct |
24 |
Correct |
60 ms |
1868 KB |
Output is correct |
25 |
Correct |
60 ms |
1888 KB |
Output is correct |
26 |
Correct |
68 ms |
1940 KB |
Output is correct |
27 |
Correct |
67 ms |
1904 KB |
Output is correct |
28 |
Correct |
68 ms |
1968 KB |
Output is correct |
29 |
Correct |
67 ms |
1888 KB |
Output is correct |
30 |
Correct |
65 ms |
1912 KB |
Output is correct |
31 |
Correct |
67 ms |
2008 KB |
Output is correct |
32 |
Correct |
68 ms |
1884 KB |
Output is correct |
33 |
Correct |
68 ms |
1888 KB |
Output is correct |
34 |
Correct |
70 ms |
1840 KB |
Output is correct |
35 |
Correct |
67 ms |
1864 KB |
Output is correct |
36 |
Correct |
68 ms |
1936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
3 ms |
532 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
404 KB |
Output is correct |
5 |
Correct |
3 ms |
552 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
7 |
Correct |
3 ms |
508 KB |
Output is correct |
8 |
Correct |
3 ms |
528 KB |
Output is correct |
9 |
Correct |
3 ms |
524 KB |
Output is correct |
10 |
Correct |
9 ms |
892 KB |
Output is correct |
11 |
Correct |
8 ms |
888 KB |
Output is correct |
12 |
Correct |
8 ms |
888 KB |
Output is correct |
13 |
Correct |
7 ms |
732 KB |
Output is correct |
14 |
Correct |
8 ms |
784 KB |
Output is correct |
15 |
Correct |
8 ms |
864 KB |
Output is correct |
16 |
Correct |
9 ms |
892 KB |
Output is correct |
17 |
Correct |
5 ms |
632 KB |
Output is correct |
18 |
Correct |
7 ms |
736 KB |
Output is correct |
19 |
Correct |
7 ms |
760 KB |
Output is correct |
20 |
Correct |
9 ms |
776 KB |
Output is correct |
21 |
Correct |
29 ms |
1424 KB |
Output is correct |
22 |
Correct |
38 ms |
1528 KB |
Output is correct |
23 |
Correct |
19 ms |
1144 KB |
Output is correct |
24 |
Correct |
60 ms |
1868 KB |
Output is correct |
25 |
Correct |
60 ms |
1888 KB |
Output is correct |
26 |
Correct |
68 ms |
1940 KB |
Output is correct |
27 |
Correct |
67 ms |
1904 KB |
Output is correct |
28 |
Correct |
68 ms |
1968 KB |
Output is correct |
29 |
Correct |
67 ms |
1888 KB |
Output is correct |
30 |
Correct |
65 ms |
1912 KB |
Output is correct |
31 |
Correct |
67 ms |
2008 KB |
Output is correct |
32 |
Correct |
68 ms |
1884 KB |
Output is correct |
33 |
Correct |
68 ms |
1888 KB |
Output is correct |
34 |
Correct |
70 ms |
1840 KB |
Output is correct |
35 |
Correct |
67 ms |
1864 KB |
Output is correct |
36 |
Correct |
68 ms |
1936 KB |
Output is correct |
37 |
Correct |
260 ms |
3572 KB |
Output is correct |
38 |
Correct |
266 ms |
3576 KB |
Output is correct |
39 |
Correct |
395 ms |
4060 KB |
Output is correct |
40 |
Correct |
476 ms |
4632 KB |
Output is correct |
41 |
Correct |
458 ms |
4396 KB |
Output is correct |
42 |
Correct |
414 ms |
4344 KB |
Output is correct |
43 |
Correct |
403 ms |
4392 KB |
Output is correct |
44 |
Correct |
431 ms |
4564 KB |
Output is correct |
45 |
Correct |
419 ms |
4536 KB |
Output is correct |
46 |
Correct |
456 ms |
4424 KB |
Output is correct |
47 |
Correct |
410 ms |
4368 KB |
Output is correct |
48 |
Correct |
418 ms |
4496 KB |
Output is correct |
49 |
Correct |
397 ms |
4220 KB |
Output is correct |
50 |
Correct |
416 ms |
4452 KB |
Output is correct |
51 |
Correct |
2 ms |
348 KB |
Output is correct |
52 |
Correct |
494 ms |
4952 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
3 ms |
532 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
404 KB |
Output is correct |
5 |
Correct |
3 ms |
552 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
7 |
Correct |
3 ms |
508 KB |
Output is correct |
8 |
Correct |
3 ms |
528 KB |
Output is correct |
9 |
Correct |
3 ms |
524 KB |
Output is correct |
10 |
Correct |
9 ms |
892 KB |
Output is correct |
11 |
Correct |
8 ms |
888 KB |
Output is correct |
12 |
Correct |
8 ms |
888 KB |
Output is correct |
13 |
Correct |
7 ms |
732 KB |
Output is correct |
14 |
Correct |
8 ms |
784 KB |
Output is correct |
15 |
Correct |
8 ms |
864 KB |
Output is correct |
16 |
Correct |
9 ms |
892 KB |
Output is correct |
17 |
Correct |
5 ms |
632 KB |
Output is correct |
18 |
Correct |
7 ms |
736 KB |
Output is correct |
19 |
Correct |
7 ms |
760 KB |
Output is correct |
20 |
Correct |
9 ms |
776 KB |
Output is correct |
21 |
Correct |
29 ms |
1424 KB |
Output is correct |
22 |
Correct |
38 ms |
1528 KB |
Output is correct |
23 |
Correct |
19 ms |
1144 KB |
Output is correct |
24 |
Correct |
60 ms |
1868 KB |
Output is correct |
25 |
Correct |
60 ms |
1888 KB |
Output is correct |
26 |
Correct |
68 ms |
1940 KB |
Output is correct |
27 |
Correct |
67 ms |
1904 KB |
Output is correct |
28 |
Correct |
68 ms |
1968 KB |
Output is correct |
29 |
Correct |
67 ms |
1888 KB |
Output is correct |
30 |
Correct |
65 ms |
1912 KB |
Output is correct |
31 |
Correct |
67 ms |
2008 KB |
Output is correct |
32 |
Correct |
68 ms |
1884 KB |
Output is correct |
33 |
Correct |
68 ms |
1888 KB |
Output is correct |
34 |
Correct |
70 ms |
1840 KB |
Output is correct |
35 |
Correct |
67 ms |
1864 KB |
Output is correct |
36 |
Correct |
68 ms |
1936 KB |
Output is correct |
37 |
Correct |
260 ms |
3572 KB |
Output is correct |
38 |
Correct |
266 ms |
3576 KB |
Output is correct |
39 |
Correct |
395 ms |
4060 KB |
Output is correct |
40 |
Correct |
476 ms |
4632 KB |
Output is correct |
41 |
Correct |
458 ms |
4396 KB |
Output is correct |
42 |
Correct |
414 ms |
4344 KB |
Output is correct |
43 |
Correct |
403 ms |
4392 KB |
Output is correct |
44 |
Correct |
431 ms |
4564 KB |
Output is correct |
45 |
Correct |
419 ms |
4536 KB |
Output is correct |
46 |
Correct |
456 ms |
4424 KB |
Output is correct |
47 |
Correct |
410 ms |
4368 KB |
Output is correct |
48 |
Correct |
418 ms |
4496 KB |
Output is correct |
49 |
Correct |
397 ms |
4220 KB |
Output is correct |
50 |
Correct |
416 ms |
4452 KB |
Output is correct |
51 |
Correct |
2 ms |
348 KB |
Output is correct |
52 |
Correct |
494 ms |
4952 KB |
Output is correct |
53 |
Correct |
600 ms |
5372 KB |
Output is correct |
54 |
Correct |
800 ms |
6096 KB |
Output is correct |
55 |
Correct |
839 ms |
6376 KB |
Output is correct |
56 |
Correct |
616 ms |
5496 KB |
Output is correct |
57 |
Correct |
844 ms |
6324 KB |
Output is correct |
58 |
Correct |
805 ms |
6248 KB |
Output is correct |
59 |
Correct |
813 ms |
6160 KB |
Output is correct |
60 |
Correct |
2 ms |
296 KB |
Output is correct |
61 |
Correct |
819 ms |
6240 KB |
Output is correct |
62 |
Correct |
694 ms |
5844 KB |
Output is correct |
63 |
Correct |
706 ms |
5792 KB |
Output is correct |
64 |
Correct |
671 ms |
5808 KB |
Output is correct |
65 |
Correct |
630 ms |
5196 KB |
Output is correct |
66 |
Correct |
611 ms |
5156 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
3 ms |
532 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
404 KB |
Output is correct |
5 |
Correct |
3 ms |
552 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
7 |
Correct |
3 ms |
508 KB |
Output is correct |
8 |
Correct |
3 ms |
528 KB |
Output is correct |
9 |
Correct |
3 ms |
524 KB |
Output is correct |
10 |
Correct |
9 ms |
892 KB |
Output is correct |
11 |
Correct |
8 ms |
888 KB |
Output is correct |
12 |
Correct |
8 ms |
888 KB |
Output is correct |
13 |
Correct |
7 ms |
732 KB |
Output is correct |
14 |
Correct |
8 ms |
784 KB |
Output is correct |
15 |
Correct |
8 ms |
864 KB |
Output is correct |
16 |
Correct |
9 ms |
892 KB |
Output is correct |
17 |
Correct |
5 ms |
632 KB |
Output is correct |
18 |
Correct |
7 ms |
736 KB |
Output is correct |
19 |
Correct |
7 ms |
760 KB |
Output is correct |
20 |
Correct |
9 ms |
776 KB |
Output is correct |
21 |
Correct |
29 ms |
1424 KB |
Output is correct |
22 |
Correct |
38 ms |
1528 KB |
Output is correct |
23 |
Correct |
19 ms |
1144 KB |
Output is correct |
24 |
Correct |
60 ms |
1868 KB |
Output is correct |
25 |
Correct |
60 ms |
1888 KB |
Output is correct |
26 |
Correct |
68 ms |
1940 KB |
Output is correct |
27 |
Correct |
67 ms |
1904 KB |
Output is correct |
28 |
Correct |
68 ms |
1968 KB |
Output is correct |
29 |
Correct |
67 ms |
1888 KB |
Output is correct |
30 |
Correct |
65 ms |
1912 KB |
Output is correct |
31 |
Correct |
67 ms |
2008 KB |
Output is correct |
32 |
Correct |
68 ms |
1884 KB |
Output is correct |
33 |
Correct |
68 ms |
1888 KB |
Output is correct |
34 |
Correct |
70 ms |
1840 KB |
Output is correct |
35 |
Correct |
67 ms |
1864 KB |
Output is correct |
36 |
Correct |
68 ms |
1936 KB |
Output is correct |
37 |
Correct |
260 ms |
3572 KB |
Output is correct |
38 |
Correct |
266 ms |
3576 KB |
Output is correct |
39 |
Correct |
395 ms |
4060 KB |
Output is correct |
40 |
Correct |
476 ms |
4632 KB |
Output is correct |
41 |
Correct |
458 ms |
4396 KB |
Output is correct |
42 |
Correct |
414 ms |
4344 KB |
Output is correct |
43 |
Correct |
403 ms |
4392 KB |
Output is correct |
44 |
Correct |
431 ms |
4564 KB |
Output is correct |
45 |
Correct |
419 ms |
4536 KB |
Output is correct |
46 |
Correct |
456 ms |
4424 KB |
Output is correct |
47 |
Correct |
410 ms |
4368 KB |
Output is correct |
48 |
Correct |
418 ms |
4496 KB |
Output is correct |
49 |
Correct |
397 ms |
4220 KB |
Output is correct |
50 |
Correct |
416 ms |
4452 KB |
Output is correct |
51 |
Correct |
2 ms |
348 KB |
Output is correct |
52 |
Correct |
494 ms |
4952 KB |
Output is correct |
53 |
Correct |
600 ms |
5372 KB |
Output is correct |
54 |
Correct |
800 ms |
6096 KB |
Output is correct |
55 |
Correct |
839 ms |
6376 KB |
Output is correct |
56 |
Correct |
616 ms |
5496 KB |
Output is correct |
57 |
Correct |
844 ms |
6324 KB |
Output is correct |
58 |
Correct |
805 ms |
6248 KB |
Output is correct |
59 |
Correct |
813 ms |
6160 KB |
Output is correct |
60 |
Correct |
2 ms |
296 KB |
Output is correct |
61 |
Correct |
819 ms |
6240 KB |
Output is correct |
62 |
Correct |
694 ms |
5844 KB |
Output is correct |
63 |
Correct |
706 ms |
5792 KB |
Output is correct |
64 |
Correct |
671 ms |
5808 KB |
Output is correct |
65 |
Correct |
630 ms |
5196 KB |
Output is correct |
66 |
Correct |
611 ms |
5156 KB |
Output is correct |
67 |
Execution timed out |
1056 ms |
6904 KB |
Time limit exceeded |
68 |
Halted |
0 ms |
0 KB |
- |