Submission #299100

# Submission time Handle Problem Language Result Execution time Memory
299100 2020-09-14T13:33:44 Z TadijaSebez Bootfall (IZhO17_bootfall) C++11
100 / 100
231 ms 19440 KB
#include <bits/stdc++.h>
using namespace std;
const int N=505;
int n,a[N];
bitset<N*N> ans[N];
void DNC(int l,int r,bitset<N*N> now){
	if(l==r)ans[l]=now;
	else{
		int mid=l+r>>1;
		bitset<N*N> tmp=now;
		for(int i=l;i<=mid;i++)tmp|=tmp<<a[i];
		DNC(mid+1,r,tmp);
		tmp=now;
		for(int i=mid+1;i<=r;i++)tmp|=tmp<<a[i];
		DNC(l,mid,tmp);
	}
}
bitset<N*N> DP(int skip){
	return ans[skip];
	/*bitset<N*N> ans;
	ans[0]=1;
	for(int i=1;i<=n;i++)if(i!=skip)ans|=ans<<a[i];
	return ans;*/
}
int ok[N*N];
int main(){
	scanf("%i",&n);
	int sum=0;
	for(int i=1;i<=n;i++)scanf("%i",&a[i]),sum+=a[i];
	bitset<N*N> e;e[0]=1;
	DNC(0,n,e);
	bitset<N*N> all=DP(0);
	if(sum&1||!all[sum/2])return 0*printf("0\n");
	for(int i=1;i<=n;i++){
		bitset<N*N> dp=DP(i);
		for(int j=1;j<=sum;j++){
			if((sum-a[i]+j)%2==0&&dp[(sum-a[i]+j)/2])
				ok[j]++;
		}
	}
	vector<int> ans;
	for(int i=1;i<=sum;i++)if(ok[i]==n)ans.push_back(i);
	printf("%i\n",ans.size());
	for(int i:ans)printf("%i ",i);
	printf("\n");
	return 0;
}

Compilation message

bootfall.cpp: In function 'void DNC(int, int, std::bitset<255025>)':
bootfall.cpp:9:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    9 |   int mid=l+r>>1;
      |           ~^~
bootfall.cpp: In function 'int main()':
bootfall.cpp:43:11: warning: format '%i' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   43 |  printf("%i\n",ans.size());
      |          ~^    ~~~~~~~~~~
      |           |            |
      |           int          std::vector<int>::size_type {aka long unsigned int}
      |          %li
bootfall.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   27 |  scanf("%i",&n);
      |  ~~~~~^~~~~~~~~
bootfall.cpp:29:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   29 |  for(int i=1;i<=n;i++)scanf("%i",&a[i]),sum+=a[i];
      |                       ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1024 KB Output is correct
2 Correct 1 ms 1024 KB Output is correct
3 Correct 1 ms 768 KB Output is correct
4 Correct 1 ms 1024 KB Output is correct
5 Correct 2 ms 1408 KB Output is correct
6 Correct 1 ms 1280 KB Output is correct
7 Correct 1 ms 1024 KB Output is correct
8 Correct 3 ms 1408 KB Output is correct
9 Correct 2 ms 1280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1024 KB Output is correct
2 Correct 1 ms 1024 KB Output is correct
3 Correct 1 ms 768 KB Output is correct
4 Correct 1 ms 1024 KB Output is correct
5 Correct 2 ms 1408 KB Output is correct
6 Correct 1 ms 1280 KB Output is correct
7 Correct 1 ms 1024 KB Output is correct
8 Correct 3 ms 1408 KB Output is correct
9 Correct 2 ms 1280 KB Output is correct
10 Correct 3 ms 2048 KB Output is correct
11 Correct 3 ms 2048 KB Output is correct
12 Correct 4 ms 2048 KB Output is correct
13 Correct 3 ms 1920 KB Output is correct
14 Correct 3 ms 2048 KB Output is correct
15 Correct 3 ms 2048 KB Output is correct
16 Correct 3 ms 2048 KB Output is correct
17 Correct 2 ms 1664 KB Output is correct
18 Correct 3 ms 1920 KB Output is correct
19 Correct 3 ms 1920 KB Output is correct
20 Correct 3 ms 2048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1024 KB Output is correct
2 Correct 1 ms 1024 KB Output is correct
3 Correct 1 ms 768 KB Output is correct
4 Correct 1 ms 1024 KB Output is correct
5 Correct 2 ms 1408 KB Output is correct
6 Correct 1 ms 1280 KB Output is correct
7 Correct 1 ms 1024 KB Output is correct
8 Correct 3 ms 1408 KB Output is correct
9 Correct 2 ms 1280 KB Output is correct
10 Correct 3 ms 2048 KB Output is correct
11 Correct 3 ms 2048 KB Output is correct
12 Correct 4 ms 2048 KB Output is correct
13 Correct 3 ms 1920 KB Output is correct
14 Correct 3 ms 2048 KB Output is correct
15 Correct 3 ms 2048 KB Output is correct
16 Correct 3 ms 2048 KB Output is correct
17 Correct 2 ms 1664 KB Output is correct
18 Correct 3 ms 1920 KB Output is correct
19 Correct 3 ms 1920 KB Output is correct
20 Correct 3 ms 2048 KB Output is correct
21 Correct 9 ms 3328 KB Output is correct
22 Correct 9 ms 3712 KB Output is correct
23 Correct 6 ms 2816 KB Output is correct
24 Correct 11 ms 4352 KB Output is correct
25 Correct 12 ms 4352 KB Output is correct
26 Correct 13 ms 4608 KB Output is correct
27 Correct 13 ms 4480 KB Output is correct
28 Correct 15 ms 4480 KB Output is correct
29 Correct 12 ms 4480 KB Output is correct
30 Correct 12 ms 4480 KB Output is correct
31 Correct 13 ms 4608 KB Output is correct
32 Correct 13 ms 4480 KB Output is correct
33 Correct 17 ms 4480 KB Output is correct
34 Correct 12 ms 4480 KB Output is correct
35 Correct 12 ms 4480 KB Output is correct
36 Correct 11 ms 4480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1024 KB Output is correct
2 Correct 1 ms 1024 KB Output is correct
3 Correct 1 ms 768 KB Output is correct
4 Correct 1 ms 1024 KB Output is correct
5 Correct 2 ms 1408 KB Output is correct
6 Correct 1 ms 1280 KB Output is correct
7 Correct 1 ms 1024 KB Output is correct
8 Correct 3 ms 1408 KB Output is correct
9 Correct 2 ms 1280 KB Output is correct
10 Correct 3 ms 2048 KB Output is correct
11 Correct 3 ms 2048 KB Output is correct
12 Correct 4 ms 2048 KB Output is correct
13 Correct 3 ms 1920 KB Output is correct
14 Correct 3 ms 2048 KB Output is correct
15 Correct 3 ms 2048 KB Output is correct
16 Correct 3 ms 2048 KB Output is correct
17 Correct 2 ms 1664 KB Output is correct
18 Correct 3 ms 1920 KB Output is correct
19 Correct 3 ms 1920 KB Output is correct
20 Correct 3 ms 2048 KB Output is correct
21 Correct 9 ms 3328 KB Output is correct
22 Correct 9 ms 3712 KB Output is correct
23 Correct 6 ms 2816 KB Output is correct
24 Correct 11 ms 4352 KB Output is correct
25 Correct 12 ms 4352 KB Output is correct
26 Correct 13 ms 4608 KB Output is correct
27 Correct 13 ms 4480 KB Output is correct
28 Correct 15 ms 4480 KB Output is correct
29 Correct 12 ms 4480 KB Output is correct
30 Correct 12 ms 4480 KB Output is correct
31 Correct 13 ms 4608 KB Output is correct
32 Correct 13 ms 4480 KB Output is correct
33 Correct 17 ms 4480 KB Output is correct
34 Correct 12 ms 4480 KB Output is correct
35 Correct 12 ms 4480 KB Output is correct
36 Correct 11 ms 4480 KB Output is correct
37 Correct 29 ms 7928 KB Output is correct
38 Correct 31 ms 7928 KB Output is correct
39 Correct 52 ms 9472 KB Output is correct
40 Correct 44 ms 10360 KB Output is correct
41 Correct 64 ms 10488 KB Output is correct
42 Correct 48 ms 9592 KB Output is correct
43 Correct 53 ms 9720 KB Output is correct
44 Correct 58 ms 9848 KB Output is correct
45 Correct 51 ms 9848 KB Output is correct
46 Correct 43 ms 10112 KB Output is correct
47 Correct 41 ms 9592 KB Output is correct
48 Correct 68 ms 9848 KB Output is correct
49 Correct 51 ms 9592 KB Output is correct
50 Correct 42 ms 9592 KB Output is correct
51 Correct 28 ms 9216 KB Output is correct
52 Correct 61 ms 10744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1024 KB Output is correct
2 Correct 1 ms 1024 KB Output is correct
3 Correct 1 ms 768 KB Output is correct
4 Correct 1 ms 1024 KB Output is correct
5 Correct 2 ms 1408 KB Output is correct
6 Correct 1 ms 1280 KB Output is correct
7 Correct 1 ms 1024 KB Output is correct
8 Correct 3 ms 1408 KB Output is correct
9 Correct 2 ms 1280 KB Output is correct
10 Correct 3 ms 2048 KB Output is correct
11 Correct 3 ms 2048 KB Output is correct
12 Correct 4 ms 2048 KB Output is correct
13 Correct 3 ms 1920 KB Output is correct
14 Correct 3 ms 2048 KB Output is correct
15 Correct 3 ms 2048 KB Output is correct
16 Correct 3 ms 2048 KB Output is correct
17 Correct 2 ms 1664 KB Output is correct
18 Correct 3 ms 1920 KB Output is correct
19 Correct 3 ms 1920 KB Output is correct
20 Correct 3 ms 2048 KB Output is correct
21 Correct 9 ms 3328 KB Output is correct
22 Correct 9 ms 3712 KB Output is correct
23 Correct 6 ms 2816 KB Output is correct
24 Correct 11 ms 4352 KB Output is correct
25 Correct 12 ms 4352 KB Output is correct
26 Correct 13 ms 4608 KB Output is correct
27 Correct 13 ms 4480 KB Output is correct
28 Correct 15 ms 4480 KB Output is correct
29 Correct 12 ms 4480 KB Output is correct
30 Correct 12 ms 4480 KB Output is correct
31 Correct 13 ms 4608 KB Output is correct
32 Correct 13 ms 4480 KB Output is correct
33 Correct 17 ms 4480 KB Output is correct
34 Correct 12 ms 4480 KB Output is correct
35 Correct 12 ms 4480 KB Output is correct
36 Correct 11 ms 4480 KB Output is correct
37 Correct 29 ms 7928 KB Output is correct
38 Correct 31 ms 7928 KB Output is correct
39 Correct 52 ms 9472 KB Output is correct
40 Correct 44 ms 10360 KB Output is correct
41 Correct 64 ms 10488 KB Output is correct
42 Correct 48 ms 9592 KB Output is correct
43 Correct 53 ms 9720 KB Output is correct
44 Correct 58 ms 9848 KB Output is correct
45 Correct 51 ms 9848 KB Output is correct
46 Correct 43 ms 10112 KB Output is correct
47 Correct 41 ms 9592 KB Output is correct
48 Correct 68 ms 9848 KB Output is correct
49 Correct 51 ms 9592 KB Output is correct
50 Correct 42 ms 9592 KB Output is correct
51 Correct 28 ms 9216 KB Output is correct
52 Correct 61 ms 10744 KB Output is correct
53 Correct 57 ms 11512 KB Output is correct
54 Correct 69 ms 13084 KB Output is correct
55 Correct 102 ms 13516 KB Output is correct
56 Correct 66 ms 11768 KB Output is correct
57 Correct 103 ms 13672 KB Output is correct
58 Correct 82 ms 13176 KB Output is correct
59 Correct 79 ms 13300 KB Output is correct
60 Correct 42 ms 12536 KB Output is correct
61 Correct 88 ms 13428 KB Output is correct
62 Correct 81 ms 12532 KB Output is correct
63 Correct 85 ms 12660 KB Output is correct
64 Correct 85 ms 12360 KB Output is correct
65 Correct 65 ms 11840 KB Output is correct
66 Correct 62 ms 11516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1024 KB Output is correct
2 Correct 1 ms 1024 KB Output is correct
3 Correct 1 ms 768 KB Output is correct
4 Correct 1 ms 1024 KB Output is correct
5 Correct 2 ms 1408 KB Output is correct
6 Correct 1 ms 1280 KB Output is correct
7 Correct 1 ms 1024 KB Output is correct
8 Correct 3 ms 1408 KB Output is correct
9 Correct 2 ms 1280 KB Output is correct
10 Correct 3 ms 2048 KB Output is correct
11 Correct 3 ms 2048 KB Output is correct
12 Correct 4 ms 2048 KB Output is correct
13 Correct 3 ms 1920 KB Output is correct
14 Correct 3 ms 2048 KB Output is correct
15 Correct 3 ms 2048 KB Output is correct
16 Correct 3 ms 2048 KB Output is correct
17 Correct 2 ms 1664 KB Output is correct
18 Correct 3 ms 1920 KB Output is correct
19 Correct 3 ms 1920 KB Output is correct
20 Correct 3 ms 2048 KB Output is correct
21 Correct 9 ms 3328 KB Output is correct
22 Correct 9 ms 3712 KB Output is correct
23 Correct 6 ms 2816 KB Output is correct
24 Correct 11 ms 4352 KB Output is correct
25 Correct 12 ms 4352 KB Output is correct
26 Correct 13 ms 4608 KB Output is correct
27 Correct 13 ms 4480 KB Output is correct
28 Correct 15 ms 4480 KB Output is correct
29 Correct 12 ms 4480 KB Output is correct
30 Correct 12 ms 4480 KB Output is correct
31 Correct 13 ms 4608 KB Output is correct
32 Correct 13 ms 4480 KB Output is correct
33 Correct 17 ms 4480 KB Output is correct
34 Correct 12 ms 4480 KB Output is correct
35 Correct 12 ms 4480 KB Output is correct
36 Correct 11 ms 4480 KB Output is correct
37 Correct 29 ms 7928 KB Output is correct
38 Correct 31 ms 7928 KB Output is correct
39 Correct 52 ms 9472 KB Output is correct
40 Correct 44 ms 10360 KB Output is correct
41 Correct 64 ms 10488 KB Output is correct
42 Correct 48 ms 9592 KB Output is correct
43 Correct 53 ms 9720 KB Output is correct
44 Correct 58 ms 9848 KB Output is correct
45 Correct 51 ms 9848 KB Output is correct
46 Correct 43 ms 10112 KB Output is correct
47 Correct 41 ms 9592 KB Output is correct
48 Correct 68 ms 9848 KB Output is correct
49 Correct 51 ms 9592 KB Output is correct
50 Correct 42 ms 9592 KB Output is correct
51 Correct 28 ms 9216 KB Output is correct
52 Correct 61 ms 10744 KB Output is correct
53 Correct 57 ms 11512 KB Output is correct
54 Correct 69 ms 13084 KB Output is correct
55 Correct 102 ms 13516 KB Output is correct
56 Correct 66 ms 11768 KB Output is correct
57 Correct 103 ms 13672 KB Output is correct
58 Correct 82 ms 13176 KB Output is correct
59 Correct 79 ms 13300 KB Output is correct
60 Correct 42 ms 12536 KB Output is correct
61 Correct 88 ms 13428 KB Output is correct
62 Correct 81 ms 12532 KB Output is correct
63 Correct 85 ms 12660 KB Output is correct
64 Correct 85 ms 12360 KB Output is correct
65 Correct 65 ms 11840 KB Output is correct
66 Correct 62 ms 11516 KB Output is correct
67 Correct 97 ms 14964 KB Output is correct
68 Correct 60 ms 17272 KB Output is correct
69 Correct 208 ms 19312 KB Output is correct
70 Correct 149 ms 18676 KB Output is correct
71 Correct 146 ms 18420 KB Output is correct
72 Correct 140 ms 17752 KB Output is correct
73 Correct 137 ms 17656 KB Output is correct
74 Correct 216 ms 19332 KB Output is correct
75 Correct 178 ms 18928 KB Output is correct
76 Correct 231 ms 19440 KB Output is correct
77 Correct 221 ms 19440 KB Output is correct