답안 #167369

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
167369 2019-12-07T18:08:30 Z GioChkhaidze Bootfall (IZhO17_bootfall) C++14
65 / 100
1000 ms 3536 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=505;
int n,S,a[N];
ll dp[N*N],mod=1e9+7;
vector < int > ans; 
bitset < N*N > A,B,C;
main () {
	cin>>n;
	
	for (int i=1; i<=n; i++) {
		cin>>a[i];
		S+=a[i];
	}
	
	sort(a+1,a+n+1);
	
	dp[0]=1;
	for (int i=1; i<=n; i++)
		for (int j=S-a[i]; j>=0; j--) {
			dp[j+a[i]]+=dp[j];
			if (dp[j+a[i]]>mod) dp[j+a[i]]-=mod;
		}
 
	if (S%2 || !dp[S/2]) {
		cout<<0<<endl;
		return 0;
	}
	
	for (int i=1; i<=S; i++)
		C[i]=1;
	
	for (int i=1; i<=n; i++) {
		for (int j=a[i]; j<=S; j++) {
			dp[j]-=dp[j-a[i]];
			if (dp[j]<0) dp[j]+=mod;
		}

		for (int j=1; j<=S; j++) {
			int X=j,Y=S-a[i]-j;
			if (Y<0) continue;
			if (!dp[X] && !dp[Y]) continue;
 			A[abs(X-Y)]=1;
		}
		
		C=A&C;
		
		for (int j=1; j<=S; j++) 
			A[j]=0;
		
		for (int j=S-a[i]; j>=0; j--) {
			dp[j+a[i]]+=dp[j];
			if (dp[j+a[i]]>mod) dp[j+a[i]]-=mod;
		}
	}

	for (int i=1; i<=S; i++)
		if (C[i]) ans.push_back(i);
 
 	cout<<ans.size()<<endl;
 	
 	for (int i=0; i<ans.size(); i++)
 		cout<<ans[i]<<" ";
}

Compilation message

bootfall.cpp:9:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main () {
       ^
bootfall.cpp: In function 'int main()':
bootfall.cpp:63:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i=0; i<ans.size(); i++)
                 ~^~~~~~~~~~~
# 결과 실행 시간 메모리 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 3 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 3 ms 380 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 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 3 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 3 ms 380 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 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 3 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 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 3 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 3 ms 380 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 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 3 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 5 ms 372 KB Output is correct
22 Correct 5 ms 376 KB Output is correct
23 Correct 4 ms 376 KB Output is correct
24 Correct 7 ms 540 KB Output is correct
25 Correct 12 ms 508 KB Output is correct
26 Correct 11 ms 504 KB Output is correct
27 Correct 11 ms 504 KB Output is correct
28 Correct 11 ms 504 KB Output is correct
29 Correct 12 ms 504 KB Output is correct
30 Correct 8 ms 504 KB Output is correct
31 Correct 10 ms 504 KB Output is correct
32 Correct 8 ms 504 KB Output is correct
33 Correct 11 ms 508 KB Output is correct
34 Correct 11 ms 504 KB Output is correct
35 Correct 11 ms 504 KB Output is correct
36 Correct 7 ms 504 KB Output is correct
# 결과 실행 시간 메모리 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 3 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 3 ms 380 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 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 3 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 5 ms 372 KB Output is correct
22 Correct 5 ms 376 KB Output is correct
23 Correct 4 ms 376 KB Output is correct
24 Correct 7 ms 540 KB Output is correct
25 Correct 12 ms 508 KB Output is correct
26 Correct 11 ms 504 KB Output is correct
27 Correct 11 ms 504 KB Output is correct
28 Correct 11 ms 504 KB Output is correct
29 Correct 12 ms 504 KB Output is correct
30 Correct 8 ms 504 KB Output is correct
31 Correct 10 ms 504 KB Output is correct
32 Correct 8 ms 504 KB Output is correct
33 Correct 11 ms 508 KB Output is correct
34 Correct 11 ms 504 KB Output is correct
35 Correct 11 ms 504 KB Output is correct
36 Correct 7 ms 504 KB Output is correct
37 Correct 39 ms 732 KB Output is correct
38 Correct 40 ms 632 KB Output is correct
39 Correct 116 ms 956 KB Output is correct
40 Correct 94 ms 888 KB Output is correct
41 Correct 149 ms 1016 KB Output is correct
42 Correct 73 ms 888 KB Output is correct
43 Correct 121 ms 1260 KB Output is correct
44 Correct 129 ms 1272 KB Output is correct
45 Correct 129 ms 1264 KB Output is correct
46 Correct 80 ms 652 KB Output is correct
47 Correct 76 ms 888 KB Output is correct
48 Correct 138 ms 1148 KB Output is correct
49 Correct 136 ms 988 KB Output is correct
50 Correct 76 ms 888 KB Output is correct
51 Correct 11 ms 632 KB Output is correct
52 Correct 168 ms 1400 KB Output is correct
# 결과 실행 시간 메모리 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 3 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 3 ms 380 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 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 3 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 5 ms 372 KB Output is correct
22 Correct 5 ms 376 KB Output is correct
23 Correct 4 ms 376 KB Output is correct
24 Correct 7 ms 540 KB Output is correct
25 Correct 12 ms 508 KB Output is correct
26 Correct 11 ms 504 KB Output is correct
27 Correct 11 ms 504 KB Output is correct
28 Correct 11 ms 504 KB Output is correct
29 Correct 12 ms 504 KB Output is correct
30 Correct 8 ms 504 KB Output is correct
31 Correct 10 ms 504 KB Output is correct
32 Correct 8 ms 504 KB Output is correct
33 Correct 11 ms 508 KB Output is correct
34 Correct 11 ms 504 KB Output is correct
35 Correct 11 ms 504 KB Output is correct
36 Correct 7 ms 504 KB Output is correct
37 Correct 39 ms 732 KB Output is correct
38 Correct 40 ms 632 KB Output is correct
39 Correct 116 ms 956 KB Output is correct
40 Correct 94 ms 888 KB Output is correct
41 Correct 149 ms 1016 KB Output is correct
42 Correct 73 ms 888 KB Output is correct
43 Correct 121 ms 1260 KB Output is correct
44 Correct 129 ms 1272 KB Output is correct
45 Correct 129 ms 1264 KB Output is correct
46 Correct 80 ms 652 KB Output is correct
47 Correct 76 ms 888 KB Output is correct
48 Correct 138 ms 1148 KB Output is correct
49 Correct 136 ms 988 KB Output is correct
50 Correct 76 ms 888 KB Output is correct
51 Correct 11 ms 632 KB Output is correct
52 Correct 168 ms 1400 KB Output is correct
53 Correct 125 ms 1060 KB Output is correct
54 Correct 172 ms 1272 KB Output is correct
55 Correct 344 ms 1908 KB Output is correct
56 Correct 157 ms 1336 KB Output is correct
57 Correct 360 ms 1996 KB Output is correct
58 Correct 191 ms 1404 KB Output is correct
59 Correct 245 ms 1524 KB Output is correct
60 Correct 27 ms 888 KB Output is correct
61 Correct 268 ms 1780 KB Output is correct
62 Correct 271 ms 1724 KB Output is correct
63 Correct 292 ms 1908 KB Output is correct
64 Correct 315 ms 1780 KB Output is correct
65 Correct 134 ms 888 KB Output is correct
66 Correct 146 ms 856 KB Output is correct
# 결과 실행 시간 메모리 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 3 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 3 ms 380 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 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 3 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 5 ms 372 KB Output is correct
22 Correct 5 ms 376 KB Output is correct
23 Correct 4 ms 376 KB Output is correct
24 Correct 7 ms 540 KB Output is correct
25 Correct 12 ms 508 KB Output is correct
26 Correct 11 ms 504 KB Output is correct
27 Correct 11 ms 504 KB Output is correct
28 Correct 11 ms 504 KB Output is correct
29 Correct 12 ms 504 KB Output is correct
30 Correct 8 ms 504 KB Output is correct
31 Correct 10 ms 504 KB Output is correct
32 Correct 8 ms 504 KB Output is correct
33 Correct 11 ms 508 KB Output is correct
34 Correct 11 ms 504 KB Output is correct
35 Correct 11 ms 504 KB Output is correct
36 Correct 7 ms 504 KB Output is correct
37 Correct 39 ms 732 KB Output is correct
38 Correct 40 ms 632 KB Output is correct
39 Correct 116 ms 956 KB Output is correct
40 Correct 94 ms 888 KB Output is correct
41 Correct 149 ms 1016 KB Output is correct
42 Correct 73 ms 888 KB Output is correct
43 Correct 121 ms 1260 KB Output is correct
44 Correct 129 ms 1272 KB Output is correct
45 Correct 129 ms 1264 KB Output is correct
46 Correct 80 ms 652 KB Output is correct
47 Correct 76 ms 888 KB Output is correct
48 Correct 138 ms 1148 KB Output is correct
49 Correct 136 ms 988 KB Output is correct
50 Correct 76 ms 888 KB Output is correct
51 Correct 11 ms 632 KB Output is correct
52 Correct 168 ms 1400 KB Output is correct
53 Correct 125 ms 1060 KB Output is correct
54 Correct 172 ms 1272 KB Output is correct
55 Correct 344 ms 1908 KB Output is correct
56 Correct 157 ms 1336 KB Output is correct
57 Correct 360 ms 1996 KB Output is correct
58 Correct 191 ms 1404 KB Output is correct
59 Correct 245 ms 1524 KB Output is correct
60 Correct 27 ms 888 KB Output is correct
61 Correct 268 ms 1780 KB Output is correct
62 Correct 271 ms 1724 KB Output is correct
63 Correct 292 ms 1908 KB Output is correct
64 Correct 315 ms 1780 KB Output is correct
65 Correct 134 ms 888 KB Output is correct
66 Correct 146 ms 856 KB Output is correct
67 Correct 289 ms 1652 KB Output is correct
68 Correct 71 ms 1272 KB Output is correct
69 Correct 967 ms 3312 KB Output is correct
70 Correct 598 ms 2216 KB Output is correct
71 Correct 553 ms 2212 KB Output is correct
72 Correct 543 ms 1400 KB Output is correct
73 Correct 542 ms 1400 KB Output is correct
74 Correct 984 ms 3536 KB Output is correct
75 Correct 764 ms 2924 KB Output is correct
76 Execution timed out 1067 ms 2424 KB Time limit exceeded
77 Halted 0 ms 0 KB -