# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
163787 |
2019-11-15T10:22:08 Z |
MvC |
Bootfall (IZhO17_bootfall) |
C++11 |
|
550 ms |
2044 KB |
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=5e2+5;
const int mmax=500*500+5;
const int mod=1e9+7;
using namespace std;
int n,a[nmax],i,j,sm,f[mmax];
bitset<mmax>bs;
int main()
{
//freopen("sol.in","r",stdin);
//freopen("sol.out","w",stdout);
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
cin>>n;
for(i=1;i<=n;i++)cin>>a[i],sm+=a[i];
if(sm&1)rc(0);
f[0]=1;
sm=0;
for(i=1;i<=n;i++)
{
for(j=sm+a[i];j>=a[i];j--)
{
f[j]+=f[j-a[i]];
if(f[j]>=mod)f[j]-=mod;
}
sm+=a[i];
}
if(!f[sm/2])rc(0);
for(i=1;i<=sm;i++)bs[i]=1;
for(i=1;i<=n;i++)
{
for(j=a[i];j<=sm;j++)
{
f[j]-=f[j-a[i]];
if(f[j]<0)f[j]+=mod;
}
for(j=1;j<=sm;j++)
{
if((sm-a[i]+j)&1 || !f[(sm-a[i]+j)/2])bs[j]=0;
}
for(j=sm;j>=a[i];j--)
{
f[j]+=f[j-a[i]];
if(f[j]>=mod)f[j]-=mod;
}
}
cout<<bs.count()<<endl;
for(i=1;i<=sm;i++)if(bs[i])cout<<i<<" ";
cout<<endl;
return 0;
}
Compilation message
bootfall.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
#pragma GCC optimization("O3")
bootfall.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
#pragma GCC optimization("unroll-loops")
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
380 KB |
Output is correct |
10 |
Correct |
2 ms |
380 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
504 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
380 KB |
Output is correct |
10 |
Correct |
2 ms |
380 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
504 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
3 ms |
376 KB |
Output is correct |
22 |
Correct |
4 ms |
380 KB |
Output is correct |
23 |
Correct |
3 ms |
504 KB |
Output is correct |
24 |
Correct |
4 ms |
376 KB |
Output is correct |
25 |
Correct |
6 ms |
376 KB |
Output is correct |
26 |
Correct |
7 ms |
376 KB |
Output is correct |
27 |
Correct |
7 ms |
376 KB |
Output is correct |
28 |
Correct |
7 ms |
376 KB |
Output is correct |
29 |
Correct |
7 ms |
376 KB |
Output is correct |
30 |
Correct |
4 ms |
376 KB |
Output is correct |
31 |
Correct |
6 ms |
504 KB |
Output is correct |
32 |
Correct |
4 ms |
376 KB |
Output is correct |
33 |
Correct |
8 ms |
380 KB |
Output is correct |
34 |
Correct |
7 ms |
424 KB |
Output is correct |
35 |
Correct |
7 ms |
376 KB |
Output is correct |
36 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
380 KB |
Output is correct |
10 |
Correct |
2 ms |
380 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
504 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
3 ms |
376 KB |
Output is correct |
22 |
Correct |
4 ms |
380 KB |
Output is correct |
23 |
Correct |
3 ms |
504 KB |
Output is correct |
24 |
Correct |
4 ms |
376 KB |
Output is correct |
25 |
Correct |
6 ms |
376 KB |
Output is correct |
26 |
Correct |
7 ms |
376 KB |
Output is correct |
27 |
Correct |
7 ms |
376 KB |
Output is correct |
28 |
Correct |
7 ms |
376 KB |
Output is correct |
29 |
Correct |
7 ms |
376 KB |
Output is correct |
30 |
Correct |
4 ms |
376 KB |
Output is correct |
31 |
Correct |
6 ms |
504 KB |
Output is correct |
32 |
Correct |
4 ms |
376 KB |
Output is correct |
33 |
Correct |
8 ms |
380 KB |
Output is correct |
34 |
Correct |
7 ms |
424 KB |
Output is correct |
35 |
Correct |
7 ms |
376 KB |
Output is correct |
36 |
Correct |
5 ms |
376 KB |
Output is correct |
37 |
Correct |
19 ms |
504 KB |
Output is correct |
38 |
Correct |
20 ms |
504 KB |
Output is correct |
39 |
Correct |
83 ms |
632 KB |
Output is correct |
40 |
Correct |
41 ms |
632 KB |
Output is correct |
41 |
Correct |
104 ms |
732 KB |
Output is correct |
42 |
Correct |
36 ms |
548 KB |
Output is correct |
43 |
Correct |
77 ms |
760 KB |
Output is correct |
44 |
Correct |
64 ms |
760 KB |
Output is correct |
45 |
Correct |
65 ms |
760 KB |
Output is correct |
46 |
Correct |
43 ms |
504 KB |
Output is correct |
47 |
Correct |
39 ms |
632 KB |
Output is correct |
48 |
Correct |
74 ms |
760 KB |
Output is correct |
49 |
Correct |
77 ms |
632 KB |
Output is correct |
50 |
Correct |
39 ms |
632 KB |
Output is correct |
51 |
Correct |
2 ms |
376 KB |
Output is correct |
52 |
Correct |
88 ms |
764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
380 KB |
Output is correct |
10 |
Correct |
2 ms |
380 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
504 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
3 ms |
376 KB |
Output is correct |
22 |
Correct |
4 ms |
380 KB |
Output is correct |
23 |
Correct |
3 ms |
504 KB |
Output is correct |
24 |
Correct |
4 ms |
376 KB |
Output is correct |
25 |
Correct |
6 ms |
376 KB |
Output is correct |
26 |
Correct |
7 ms |
376 KB |
Output is correct |
27 |
Correct |
7 ms |
376 KB |
Output is correct |
28 |
Correct |
7 ms |
376 KB |
Output is correct |
29 |
Correct |
7 ms |
376 KB |
Output is correct |
30 |
Correct |
4 ms |
376 KB |
Output is correct |
31 |
Correct |
6 ms |
504 KB |
Output is correct |
32 |
Correct |
4 ms |
376 KB |
Output is correct |
33 |
Correct |
8 ms |
380 KB |
Output is correct |
34 |
Correct |
7 ms |
424 KB |
Output is correct |
35 |
Correct |
7 ms |
376 KB |
Output is correct |
36 |
Correct |
5 ms |
376 KB |
Output is correct |
37 |
Correct |
19 ms |
504 KB |
Output is correct |
38 |
Correct |
20 ms |
504 KB |
Output is correct |
39 |
Correct |
83 ms |
632 KB |
Output is correct |
40 |
Correct |
41 ms |
632 KB |
Output is correct |
41 |
Correct |
104 ms |
732 KB |
Output is correct |
42 |
Correct |
36 ms |
548 KB |
Output is correct |
43 |
Correct |
77 ms |
760 KB |
Output is correct |
44 |
Correct |
64 ms |
760 KB |
Output is correct |
45 |
Correct |
65 ms |
760 KB |
Output is correct |
46 |
Correct |
43 ms |
504 KB |
Output is correct |
47 |
Correct |
39 ms |
632 KB |
Output is correct |
48 |
Correct |
74 ms |
760 KB |
Output is correct |
49 |
Correct |
77 ms |
632 KB |
Output is correct |
50 |
Correct |
39 ms |
632 KB |
Output is correct |
51 |
Correct |
2 ms |
376 KB |
Output is correct |
52 |
Correct |
88 ms |
764 KB |
Output is correct |
53 |
Correct |
64 ms |
708 KB |
Output is correct |
54 |
Correct |
87 ms |
760 KB |
Output is correct |
55 |
Correct |
176 ms |
1116 KB |
Output is correct |
56 |
Correct |
79 ms |
860 KB |
Output is correct |
57 |
Correct |
186 ms |
1144 KB |
Output is correct |
58 |
Correct |
96 ms |
888 KB |
Output is correct |
59 |
Correct |
125 ms |
840 KB |
Output is correct |
60 |
Correct |
2 ms |
376 KB |
Output is correct |
61 |
Correct |
135 ms |
988 KB |
Output is correct |
62 |
Correct |
138 ms |
1016 KB |
Output is correct |
63 |
Correct |
153 ms |
1144 KB |
Output is correct |
64 |
Correct |
146 ms |
1096 KB |
Output is correct |
65 |
Correct |
82 ms |
624 KB |
Output is correct |
66 |
Correct |
85 ms |
760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
380 KB |
Output is correct |
10 |
Correct |
2 ms |
380 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
504 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
3 ms |
376 KB |
Output is correct |
22 |
Correct |
4 ms |
380 KB |
Output is correct |
23 |
Correct |
3 ms |
504 KB |
Output is correct |
24 |
Correct |
4 ms |
376 KB |
Output is correct |
25 |
Correct |
6 ms |
376 KB |
Output is correct |
26 |
Correct |
7 ms |
376 KB |
Output is correct |
27 |
Correct |
7 ms |
376 KB |
Output is correct |
28 |
Correct |
7 ms |
376 KB |
Output is correct |
29 |
Correct |
7 ms |
376 KB |
Output is correct |
30 |
Correct |
4 ms |
376 KB |
Output is correct |
31 |
Correct |
6 ms |
504 KB |
Output is correct |
32 |
Correct |
4 ms |
376 KB |
Output is correct |
33 |
Correct |
8 ms |
380 KB |
Output is correct |
34 |
Correct |
7 ms |
424 KB |
Output is correct |
35 |
Correct |
7 ms |
376 KB |
Output is correct |
36 |
Correct |
5 ms |
376 KB |
Output is correct |
37 |
Correct |
19 ms |
504 KB |
Output is correct |
38 |
Correct |
20 ms |
504 KB |
Output is correct |
39 |
Correct |
83 ms |
632 KB |
Output is correct |
40 |
Correct |
41 ms |
632 KB |
Output is correct |
41 |
Correct |
104 ms |
732 KB |
Output is correct |
42 |
Correct |
36 ms |
548 KB |
Output is correct |
43 |
Correct |
77 ms |
760 KB |
Output is correct |
44 |
Correct |
64 ms |
760 KB |
Output is correct |
45 |
Correct |
65 ms |
760 KB |
Output is correct |
46 |
Correct |
43 ms |
504 KB |
Output is correct |
47 |
Correct |
39 ms |
632 KB |
Output is correct |
48 |
Correct |
74 ms |
760 KB |
Output is correct |
49 |
Correct |
77 ms |
632 KB |
Output is correct |
50 |
Correct |
39 ms |
632 KB |
Output is correct |
51 |
Correct |
2 ms |
376 KB |
Output is correct |
52 |
Correct |
88 ms |
764 KB |
Output is correct |
53 |
Correct |
64 ms |
708 KB |
Output is correct |
54 |
Correct |
87 ms |
760 KB |
Output is correct |
55 |
Correct |
176 ms |
1116 KB |
Output is correct |
56 |
Correct |
79 ms |
860 KB |
Output is correct |
57 |
Correct |
186 ms |
1144 KB |
Output is correct |
58 |
Correct |
96 ms |
888 KB |
Output is correct |
59 |
Correct |
125 ms |
840 KB |
Output is correct |
60 |
Correct |
2 ms |
376 KB |
Output is correct |
61 |
Correct |
135 ms |
988 KB |
Output is correct |
62 |
Correct |
138 ms |
1016 KB |
Output is correct |
63 |
Correct |
153 ms |
1144 KB |
Output is correct |
64 |
Correct |
146 ms |
1096 KB |
Output is correct |
65 |
Correct |
82 ms |
624 KB |
Output is correct |
66 |
Correct |
85 ms |
760 KB |
Output is correct |
67 |
Correct |
136 ms |
892 KB |
Output is correct |
68 |
Correct |
35 ms |
860 KB |
Output is correct |
69 |
Correct |
465 ms |
1940 KB |
Output is correct |
70 |
Correct |
285 ms |
1288 KB |
Output is correct |
71 |
Correct |
302 ms |
1272 KB |
Output is correct |
72 |
Correct |
274 ms |
888 KB |
Output is correct |
73 |
Correct |
271 ms |
888 KB |
Output is correct |
74 |
Correct |
490 ms |
2040 KB |
Output is correct |
75 |
Correct |
389 ms |
1632 KB |
Output is correct |
76 |
Correct |
550 ms |
2044 KB |
Output is correct |
77 |
Correct |
525 ms |
2040 KB |
Output is correct |