답안 #925552

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
925552 2024-02-12T04:07:16 Z WanWan Bootfall (IZhO17_bootfall) C++14
28 / 100
1000 ms 5272 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long 

const int MOD1 = (int)1e9 + 7;
const int MOD2 = 998244353;
const int MOD3 = (int)1e9 + 9;
int n;
int A[505];
int ways[505*505][3];
int cnt[505*500];
int32_t main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	vector<int> MODS={MOD1,MOD2,MOD3};
	cin>>n;
	int sum=0;
	for(int i=1;i<=n;i++){
		cin>>A[i];
		sum+=A[i];
	}
	ways[0][0]=1;
	ways[0][1]=1;
	ways[0][2]=1;

	for(int i=1;i<=n;i++){
		for(int j=sum;j>=0;j--){
			for(int k=0;k<=2;k++){
				if(j-A[i]>=0)ways[j][k]=(ways[j][k]+ways[j-A[i]][k])%MODS[k];
			}
		}
	}
	unordered_set<int>os;
	if(sum % 2 == 1){
		return cout << 0,0;
	}
	if(ways[sum/2][0] == 0 && ways[sum/2][1] == 0 && ways[sum/2][2] == 0){
		return cout << 0,0;
	}

	for(int i=1;i<=n;i++){ // remove this
		unordered_set<int>os;
		for(int j=0;j<=sum;j++){
			for(int k=0;k<=2;k++){
				if(j-A[i]>=0)ways[j][k]=(ways[j][k]-ways[j-A[i]][k]+MODS[k])%MODS[k];
			}
			if(ways[j][0] != 0 && ways[j][1] != 0 && ways[j][2] != 0){
				int diff=abs(j-((sum-A[i])-j));
				os.insert(diff);
			}
			
		}
		for(auto x:os){
			if(x>=0)cnt[x]++;
		}
		for(int j=sum;j>=0;j--){
			for(int k=0;k<=2;k++){
				if(j-A[i]>=0)ways[j][k]=(ways[j][k]+ways[j-A[i]][k])%MODS[k];
			}
		}
	}
	vector<int>out;
	for(int j=1;j<=sum;j++){

		if(cnt[j] == n){
			out.push_back(j);
		}
	}
	cout<<out.size()<<"\n";
	for(auto x:out)cout<<x<<" ";

}	
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2552 KB Output is correct
6 Correct 1 ms 2648 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2552 KB Output is correct
6 Correct 1 ms 2648 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2524 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2552 KB Output is correct
6 Correct 1 ms 2648 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2524 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 14 ms 2396 KB Output is correct
22 Correct 16 ms 2392 KB Output is correct
23 Correct 8 ms 2396 KB Output is correct
24 Correct 29 ms 2656 KB Output is correct
25 Correct 49 ms 2764 KB Output is correct
26 Correct 55 ms 2728 KB Output is correct
27 Correct 44 ms 2652 KB Output is correct
28 Correct 46 ms 2652 KB Output is correct
29 Correct 49 ms 2652 KB Output is correct
30 Correct 34 ms 2652 KB Output is correct
31 Correct 46 ms 2720 KB Output is correct
32 Correct 30 ms 2652 KB Output is correct
33 Correct 39 ms 2396 KB Output is correct
34 Correct 39 ms 2516 KB Output is correct
35 Correct 48 ms 2652 KB Output is correct
36 Correct 29 ms 2648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2552 KB Output is correct
6 Correct 1 ms 2648 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2524 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 14 ms 2396 KB Output is correct
22 Correct 16 ms 2392 KB Output is correct
23 Correct 8 ms 2396 KB Output is correct
24 Correct 29 ms 2656 KB Output is correct
25 Correct 49 ms 2764 KB Output is correct
26 Correct 55 ms 2728 KB Output is correct
27 Correct 44 ms 2652 KB Output is correct
28 Correct 46 ms 2652 KB Output is correct
29 Correct 49 ms 2652 KB Output is correct
30 Correct 34 ms 2652 KB Output is correct
31 Correct 46 ms 2720 KB Output is correct
32 Correct 30 ms 2652 KB Output is correct
33 Correct 39 ms 2396 KB Output is correct
34 Correct 39 ms 2516 KB Output is correct
35 Correct 48 ms 2652 KB Output is correct
36 Correct 29 ms 2648 KB Output is correct
37 Correct 247 ms 3244 KB Output is correct
38 Correct 244 ms 3260 KB Output is correct
39 Correct 595 ms 3960 KB Output is correct
40 Correct 553 ms 3944 KB Output is correct
41 Correct 759 ms 4132 KB Output is correct
42 Correct 471 ms 3760 KB Output is correct
43 Correct 835 ms 4872 KB Output is correct
44 Correct 859 ms 4916 KB Output is correct
45 Correct 884 ms 4936 KB Output is correct
46 Correct 437 ms 3500 KB Output is correct
47 Correct 510 ms 3864 KB Output is correct
48 Correct 928 ms 5076 KB Output is correct
49 Correct 771 ms 4472 KB Output is correct
50 Correct 506 ms 4004 KB Output is correct
51 Correct 101 ms 2908 KB Output is correct
52 Execution timed out 1075 ms 5272 KB Time limit exceeded
53 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2552 KB Output is correct
6 Correct 1 ms 2648 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2524 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 14 ms 2396 KB Output is correct
22 Correct 16 ms 2392 KB Output is correct
23 Correct 8 ms 2396 KB Output is correct
24 Correct 29 ms 2656 KB Output is correct
25 Correct 49 ms 2764 KB Output is correct
26 Correct 55 ms 2728 KB Output is correct
27 Correct 44 ms 2652 KB Output is correct
28 Correct 46 ms 2652 KB Output is correct
29 Correct 49 ms 2652 KB Output is correct
30 Correct 34 ms 2652 KB Output is correct
31 Correct 46 ms 2720 KB Output is correct
32 Correct 30 ms 2652 KB Output is correct
33 Correct 39 ms 2396 KB Output is correct
34 Correct 39 ms 2516 KB Output is correct
35 Correct 48 ms 2652 KB Output is correct
36 Correct 29 ms 2648 KB Output is correct
37 Correct 247 ms 3244 KB Output is correct
38 Correct 244 ms 3260 KB Output is correct
39 Correct 595 ms 3960 KB Output is correct
40 Correct 553 ms 3944 KB Output is correct
41 Correct 759 ms 4132 KB Output is correct
42 Correct 471 ms 3760 KB Output is correct
43 Correct 835 ms 4872 KB Output is correct
44 Correct 859 ms 4916 KB Output is correct
45 Correct 884 ms 4936 KB Output is correct
46 Correct 437 ms 3500 KB Output is correct
47 Correct 510 ms 3864 KB Output is correct
48 Correct 928 ms 5076 KB Output is correct
49 Correct 771 ms 4472 KB Output is correct
50 Correct 506 ms 4004 KB Output is correct
51 Correct 101 ms 2908 KB Output is correct
52 Execution timed out 1075 ms 5272 KB Time limit exceeded
53 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2552 KB Output is correct
6 Correct 1 ms 2648 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2524 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 14 ms 2396 KB Output is correct
22 Correct 16 ms 2392 KB Output is correct
23 Correct 8 ms 2396 KB Output is correct
24 Correct 29 ms 2656 KB Output is correct
25 Correct 49 ms 2764 KB Output is correct
26 Correct 55 ms 2728 KB Output is correct
27 Correct 44 ms 2652 KB Output is correct
28 Correct 46 ms 2652 KB Output is correct
29 Correct 49 ms 2652 KB Output is correct
30 Correct 34 ms 2652 KB Output is correct
31 Correct 46 ms 2720 KB Output is correct
32 Correct 30 ms 2652 KB Output is correct
33 Correct 39 ms 2396 KB Output is correct
34 Correct 39 ms 2516 KB Output is correct
35 Correct 48 ms 2652 KB Output is correct
36 Correct 29 ms 2648 KB Output is correct
37 Correct 247 ms 3244 KB Output is correct
38 Correct 244 ms 3260 KB Output is correct
39 Correct 595 ms 3960 KB Output is correct
40 Correct 553 ms 3944 KB Output is correct
41 Correct 759 ms 4132 KB Output is correct
42 Correct 471 ms 3760 KB Output is correct
43 Correct 835 ms 4872 KB Output is correct
44 Correct 859 ms 4916 KB Output is correct
45 Correct 884 ms 4936 KB Output is correct
46 Correct 437 ms 3500 KB Output is correct
47 Correct 510 ms 3864 KB Output is correct
48 Correct 928 ms 5076 KB Output is correct
49 Correct 771 ms 4472 KB Output is correct
50 Correct 506 ms 4004 KB Output is correct
51 Correct 101 ms 2908 KB Output is correct
52 Execution timed out 1075 ms 5272 KB Time limit exceeded
53 Halted 0 ms 0 KB -