Submission #888388

# Submission time Handle Problem Language Result Execution time Memory
888388 2023-12-17T08:55:32 Z pcc Bootfall (IZhO17_bootfall) C++14
44 / 100
1000 ms 10324 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>

const int mxn = 510*2;
const int C = mxn*mxn;
int mod = 998244353;
int arr[mxn];
int dp[C];
int del[C];
int n;
int sum = 0;
bitset<C> able;

inline ll mad(int a,int b){
	a += b;
	return a>=mod?a-mod:a;
}
inline ll mub(int a,int b){
	return mad(a,mod-b);
}

inline bool check(int now,int tsum){
	if(sum&1)return false;
	if(!dp[sum>>1])return false;
	if(tsum&1)return false;
	if(tsum/2<now)return false;
	if(!del[tsum>>1])return false;
	return true;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	dp[0] = 1;
	for(int i = 1;i<=n;i++){
		cin>>arr[i];
		sum += arr[i];
		for(int j = C-1;j>=arr[i];j--)dp[j] =mad(dp[j],dp[j-arr[i]]);
	}

	set<int> ans;
	able.set();
	for(int i = 1;i<=n;i++){
		for(int j = 0;j<C;j++)del[j] = dp[j];
		for(int j = arr[i];j<C;j++)del[j] = mub(del[j],del[j-arr[i]]);
		for(int j = 1;j<=sum;j++){
			if(!check(j,sum-arr[i]+j))able[j] = false;
		}
	}
	for(int j = 1;j<=sum;j++)if(able[j])ans.insert(j);

	memset(dp,0,sizeof(dp));
	mod = 998244353;
	dp[0] = 1;
	able.set();
	for(int i = 1;i<=n;i++){
		for(int j = 0;j<C;j++)del[j] = dp[j];
		for(int j = arr[i];j<C;j++)del[j] = mub(del[j],del[j-arr[i]]);
		for(int j = 1;j<=sum;j++){
			if(!check(j,sum-arr[i]+j))able[j] = false;
		}
	}
	for(int j = 1;j<=sum;j++)if(able[j])ans.insert(j);

	/*
	for(int i = 0;i<=10;i++)cout<<dp[i]<<' ';cout<<endl;
	cout<<sum<<endl;
	cout<<endl;
	for(int i = 1;i<=n;i++){
		for(int j = 0;j<=10;j++)cout<<del[i][j]<<' ';cout<<endl;
	}
   */

	cout<<ans.size()<<'\n';
	for(auto &i:ans)cout<<i<<' ';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 28 ms 8536 KB Output is correct
2 Correct 23 ms 8540 KB Output is correct
3 Correct 19 ms 8724 KB Output is correct
4 Correct 15 ms 8536 KB Output is correct
5 Correct 41 ms 8556 KB Output is correct
6 Correct 28 ms 8540 KB Output is correct
7 Correct 22 ms 8540 KB Output is correct
8 Correct 44 ms 8724 KB Output is correct
9 Correct 34 ms 8540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 8536 KB Output is correct
2 Correct 23 ms 8540 KB Output is correct
3 Correct 19 ms 8724 KB Output is correct
4 Correct 15 ms 8536 KB Output is correct
5 Correct 41 ms 8556 KB Output is correct
6 Correct 28 ms 8540 KB Output is correct
7 Correct 22 ms 8540 KB Output is correct
8 Correct 44 ms 8724 KB Output is correct
9 Correct 34 ms 8540 KB Output is correct
10 Correct 97 ms 8700 KB Output is correct
11 Correct 121 ms 8540 KB Output is correct
12 Correct 101 ms 8544 KB Output is correct
13 Correct 100 ms 8704 KB Output is correct
14 Correct 98 ms 8712 KB Output is correct
15 Correct 116 ms 8528 KB Output is correct
16 Correct 126 ms 8700 KB Output is correct
17 Correct 73 ms 8704 KB Output is correct
18 Correct 87 ms 8528 KB Output is correct
19 Correct 95 ms 8540 KB Output is correct
20 Correct 99 ms 8540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 8536 KB Output is correct
2 Correct 23 ms 8540 KB Output is correct
3 Correct 19 ms 8724 KB Output is correct
4 Correct 15 ms 8536 KB Output is correct
5 Correct 41 ms 8556 KB Output is correct
6 Correct 28 ms 8540 KB Output is correct
7 Correct 22 ms 8540 KB Output is correct
8 Correct 44 ms 8724 KB Output is correct
9 Correct 34 ms 8540 KB Output is correct
10 Correct 97 ms 8700 KB Output is correct
11 Correct 121 ms 8540 KB Output is correct
12 Correct 101 ms 8544 KB Output is correct
13 Correct 100 ms 8704 KB Output is correct
14 Correct 98 ms 8712 KB Output is correct
15 Correct 116 ms 8528 KB Output is correct
16 Correct 126 ms 8700 KB Output is correct
17 Correct 73 ms 8704 KB Output is correct
18 Correct 87 ms 8528 KB Output is correct
19 Correct 95 ms 8540 KB Output is correct
20 Correct 99 ms 8540 KB Output is correct
21 Correct 222 ms 8776 KB Output is correct
22 Correct 247 ms 8780 KB Output is correct
23 Correct 173 ms 8784 KB Output is correct
24 Correct 324 ms 8784 KB Output is correct
25 Correct 305 ms 8788 KB Output is correct
26 Correct 323 ms 8860 KB Output is correct
27 Correct 319 ms 8796 KB Output is correct
28 Correct 320 ms 8544 KB Output is correct
29 Correct 325 ms 8544 KB Output is correct
30 Correct 326 ms 8528 KB Output is correct
31 Correct 325 ms 9120 KB Output is correct
32 Correct 335 ms 8788 KB Output is correct
33 Correct 327 ms 8960 KB Output is correct
34 Correct 325 ms 8532 KB Output is correct
35 Correct 329 ms 8784 KB Output is correct
36 Correct 343 ms 8792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 8536 KB Output is correct
2 Correct 23 ms 8540 KB Output is correct
3 Correct 19 ms 8724 KB Output is correct
4 Correct 15 ms 8536 KB Output is correct
5 Correct 41 ms 8556 KB Output is correct
6 Correct 28 ms 8540 KB Output is correct
7 Correct 22 ms 8540 KB Output is correct
8 Correct 44 ms 8724 KB Output is correct
9 Correct 34 ms 8540 KB Output is correct
10 Correct 97 ms 8700 KB Output is correct
11 Correct 121 ms 8540 KB Output is correct
12 Correct 101 ms 8544 KB Output is correct
13 Correct 100 ms 8704 KB Output is correct
14 Correct 98 ms 8712 KB Output is correct
15 Correct 116 ms 8528 KB Output is correct
16 Correct 126 ms 8700 KB Output is correct
17 Correct 73 ms 8704 KB Output is correct
18 Correct 87 ms 8528 KB Output is correct
19 Correct 95 ms 8540 KB Output is correct
20 Correct 99 ms 8540 KB Output is correct
21 Correct 222 ms 8776 KB Output is correct
22 Correct 247 ms 8780 KB Output is correct
23 Correct 173 ms 8784 KB Output is correct
24 Correct 324 ms 8784 KB Output is correct
25 Correct 305 ms 8788 KB Output is correct
26 Correct 323 ms 8860 KB Output is correct
27 Correct 319 ms 8796 KB Output is correct
28 Correct 320 ms 8544 KB Output is correct
29 Correct 325 ms 8544 KB Output is correct
30 Correct 326 ms 8528 KB Output is correct
31 Correct 325 ms 9120 KB Output is correct
32 Correct 335 ms 8788 KB Output is correct
33 Correct 327 ms 8960 KB Output is correct
34 Correct 325 ms 8532 KB Output is correct
35 Correct 329 ms 8784 KB Output is correct
36 Correct 343 ms 8792 KB Output is correct
37 Correct 662 ms 9040 KB Output is correct
38 Correct 660 ms 9168 KB Output is correct
39 Correct 863 ms 8784 KB Output is correct
40 Correct 911 ms 9808 KB Output is correct
41 Correct 940 ms 8796 KB Output is correct
42 Correct 832 ms 9552 KB Output is correct
43 Correct 835 ms 10068 KB Output is correct
44 Correct 854 ms 10064 KB Output is correct
45 Correct 856 ms 10324 KB Output is correct
46 Correct 898 ms 8784 KB Output is correct
47 Correct 841 ms 9556 KB Output is correct
48 Correct 866 ms 9552 KB Output is correct
49 Correct 865 ms 9048 KB Output is correct
50 Correct 864 ms 9552 KB Output is correct
51 Correct 837 ms 8708 KB Output is correct
52 Correct 943 ms 10324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 8536 KB Output is correct
2 Correct 23 ms 8540 KB Output is correct
3 Correct 19 ms 8724 KB Output is correct
4 Correct 15 ms 8536 KB Output is correct
5 Correct 41 ms 8556 KB Output is correct
6 Correct 28 ms 8540 KB Output is correct
7 Correct 22 ms 8540 KB Output is correct
8 Correct 44 ms 8724 KB Output is correct
9 Correct 34 ms 8540 KB Output is correct
10 Correct 97 ms 8700 KB Output is correct
11 Correct 121 ms 8540 KB Output is correct
12 Correct 101 ms 8544 KB Output is correct
13 Correct 100 ms 8704 KB Output is correct
14 Correct 98 ms 8712 KB Output is correct
15 Correct 116 ms 8528 KB Output is correct
16 Correct 126 ms 8700 KB Output is correct
17 Correct 73 ms 8704 KB Output is correct
18 Correct 87 ms 8528 KB Output is correct
19 Correct 95 ms 8540 KB Output is correct
20 Correct 99 ms 8540 KB Output is correct
21 Correct 222 ms 8776 KB Output is correct
22 Correct 247 ms 8780 KB Output is correct
23 Correct 173 ms 8784 KB Output is correct
24 Correct 324 ms 8784 KB Output is correct
25 Correct 305 ms 8788 KB Output is correct
26 Correct 323 ms 8860 KB Output is correct
27 Correct 319 ms 8796 KB Output is correct
28 Correct 320 ms 8544 KB Output is correct
29 Correct 325 ms 8544 KB Output is correct
30 Correct 326 ms 8528 KB Output is correct
31 Correct 325 ms 9120 KB Output is correct
32 Correct 335 ms 8788 KB Output is correct
33 Correct 327 ms 8960 KB Output is correct
34 Correct 325 ms 8532 KB Output is correct
35 Correct 329 ms 8784 KB Output is correct
36 Correct 343 ms 8792 KB Output is correct
37 Correct 662 ms 9040 KB Output is correct
38 Correct 660 ms 9168 KB Output is correct
39 Correct 863 ms 8784 KB Output is correct
40 Correct 911 ms 9808 KB Output is correct
41 Correct 940 ms 8796 KB Output is correct
42 Correct 832 ms 9552 KB Output is correct
43 Correct 835 ms 10068 KB Output is correct
44 Correct 854 ms 10064 KB Output is correct
45 Correct 856 ms 10324 KB Output is correct
46 Correct 898 ms 8784 KB Output is correct
47 Correct 841 ms 9556 KB Output is correct
48 Correct 866 ms 9552 KB Output is correct
49 Correct 865 ms 9048 KB Output is correct
50 Correct 864 ms 9552 KB Output is correct
51 Correct 837 ms 8708 KB Output is correct
52 Correct 943 ms 10324 KB Output is correct
53 Execution timed out 1008 ms 9816 KB Time limit exceeded
54 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 28 ms 8536 KB Output is correct
2 Correct 23 ms 8540 KB Output is correct
3 Correct 19 ms 8724 KB Output is correct
4 Correct 15 ms 8536 KB Output is correct
5 Correct 41 ms 8556 KB Output is correct
6 Correct 28 ms 8540 KB Output is correct
7 Correct 22 ms 8540 KB Output is correct
8 Correct 44 ms 8724 KB Output is correct
9 Correct 34 ms 8540 KB Output is correct
10 Correct 97 ms 8700 KB Output is correct
11 Correct 121 ms 8540 KB Output is correct
12 Correct 101 ms 8544 KB Output is correct
13 Correct 100 ms 8704 KB Output is correct
14 Correct 98 ms 8712 KB Output is correct
15 Correct 116 ms 8528 KB Output is correct
16 Correct 126 ms 8700 KB Output is correct
17 Correct 73 ms 8704 KB Output is correct
18 Correct 87 ms 8528 KB Output is correct
19 Correct 95 ms 8540 KB Output is correct
20 Correct 99 ms 8540 KB Output is correct
21 Correct 222 ms 8776 KB Output is correct
22 Correct 247 ms 8780 KB Output is correct
23 Correct 173 ms 8784 KB Output is correct
24 Correct 324 ms 8784 KB Output is correct
25 Correct 305 ms 8788 KB Output is correct
26 Correct 323 ms 8860 KB Output is correct
27 Correct 319 ms 8796 KB Output is correct
28 Correct 320 ms 8544 KB Output is correct
29 Correct 325 ms 8544 KB Output is correct
30 Correct 326 ms 8528 KB Output is correct
31 Correct 325 ms 9120 KB Output is correct
32 Correct 335 ms 8788 KB Output is correct
33 Correct 327 ms 8960 KB Output is correct
34 Correct 325 ms 8532 KB Output is correct
35 Correct 329 ms 8784 KB Output is correct
36 Correct 343 ms 8792 KB Output is correct
37 Correct 662 ms 9040 KB Output is correct
38 Correct 660 ms 9168 KB Output is correct
39 Correct 863 ms 8784 KB Output is correct
40 Correct 911 ms 9808 KB Output is correct
41 Correct 940 ms 8796 KB Output is correct
42 Correct 832 ms 9552 KB Output is correct
43 Correct 835 ms 10068 KB Output is correct
44 Correct 854 ms 10064 KB Output is correct
45 Correct 856 ms 10324 KB Output is correct
46 Correct 898 ms 8784 KB Output is correct
47 Correct 841 ms 9556 KB Output is correct
48 Correct 866 ms 9552 KB Output is correct
49 Correct 865 ms 9048 KB Output is correct
50 Correct 864 ms 9552 KB Output is correct
51 Correct 837 ms 8708 KB Output is correct
52 Correct 943 ms 10324 KB Output is correct
53 Execution timed out 1008 ms 9816 KB Time limit exceeded
54 Halted 0 ms 0 KB -