# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
888394 |
2023-12-17T09:14:45 Z |
pcc |
Bootfall (IZhO17_bootfall) |
C++14 |
|
1000 ms |
3924 KB |
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,popcnt")
#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>
mt19937 seed(time(NULL));
#define rnd(l,r) uniform_int_distribution<int>(l,r)(seed)
const int mxn = 510;
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;
set<int> ans;
inline int mad(int a,int b){
a += b;
return a>=mod?a-mod:a;
}
inline int 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(now+now>tsum)return false;
if(!del[tsum>>1])return false;
return true;
}
inline void relax(int tar){
mod = tar;
memset(dp,0,sizeof(dp));
dp[0] = 1;
able.set();
for(int i = 1;i<=n;i++){
for(int j = C-1;j>=arr[i];j--)dp[j] = mad(dp[j],dp[j-arr[i]]);
}
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);
}
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];
}
int lim = CLOCKS_PER_SEC*0.95;
int st = clock();
relax((int)1e9+7);
relax((int)712271227);
relax((int)1e8+7);
relax(113);
relax(998244353);
relax(101010111);
const int inf = 1e9+10;
//cout<<rnd(0,inf);
while(clock()-st<=lim)relax(rnd(0,inf));
/*
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;
}
sort(ans.begin(),ans.end());
ans.erase(unique(ans.begin(),ans.end()),ans.end());
*/
cout<<ans.size()<<'\n';
for(auto &i:ans)cout<<i<<' ';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
951 ms |
2504 KB |
Output is correct |
2 |
Correct |
952 ms |
2504 KB |
Output is correct |
3 |
Correct |
951 ms |
2504 KB |
Output is correct |
4 |
Correct |
951 ms |
2508 KB |
Output is correct |
5 |
Correct |
953 ms |
2644 KB |
Output is correct |
6 |
Correct |
951 ms |
2524 KB |
Output is correct |
7 |
Correct |
951 ms |
2644 KB |
Output is correct |
8 |
Correct |
951 ms |
2644 KB |
Output is correct |
9 |
Correct |
951 ms |
2500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
951 ms |
2504 KB |
Output is correct |
2 |
Correct |
952 ms |
2504 KB |
Output is correct |
3 |
Correct |
951 ms |
2504 KB |
Output is correct |
4 |
Correct |
951 ms |
2508 KB |
Output is correct |
5 |
Correct |
953 ms |
2644 KB |
Output is correct |
6 |
Correct |
951 ms |
2524 KB |
Output is correct |
7 |
Correct |
951 ms |
2644 KB |
Output is correct |
8 |
Correct |
951 ms |
2644 KB |
Output is correct |
9 |
Correct |
951 ms |
2500 KB |
Output is correct |
10 |
Correct |
955 ms |
2504 KB |
Output is correct |
11 |
Correct |
962 ms |
2520 KB |
Output is correct |
12 |
Correct |
954 ms |
2520 KB |
Output is correct |
13 |
Correct |
959 ms |
2640 KB |
Output is correct |
14 |
Correct |
959 ms |
2512 KB |
Output is correct |
15 |
Correct |
955 ms |
2396 KB |
Output is correct |
16 |
Correct |
951 ms |
2504 KB |
Output is correct |
17 |
Correct |
953 ms |
2644 KB |
Output is correct |
18 |
Correct |
955 ms |
2504 KB |
Output is correct |
19 |
Correct |
951 ms |
2504 KB |
Output is correct |
20 |
Correct |
955 ms |
2500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
951 ms |
2504 KB |
Output is correct |
2 |
Correct |
952 ms |
2504 KB |
Output is correct |
3 |
Correct |
951 ms |
2504 KB |
Output is correct |
4 |
Correct |
951 ms |
2508 KB |
Output is correct |
5 |
Correct |
953 ms |
2644 KB |
Output is correct |
6 |
Correct |
951 ms |
2524 KB |
Output is correct |
7 |
Correct |
951 ms |
2644 KB |
Output is correct |
8 |
Correct |
951 ms |
2644 KB |
Output is correct |
9 |
Correct |
951 ms |
2500 KB |
Output is correct |
10 |
Correct |
955 ms |
2504 KB |
Output is correct |
11 |
Correct |
962 ms |
2520 KB |
Output is correct |
12 |
Correct |
954 ms |
2520 KB |
Output is correct |
13 |
Correct |
959 ms |
2640 KB |
Output is correct |
14 |
Correct |
959 ms |
2512 KB |
Output is correct |
15 |
Correct |
955 ms |
2396 KB |
Output is correct |
16 |
Correct |
951 ms |
2504 KB |
Output is correct |
17 |
Correct |
953 ms |
2644 KB |
Output is correct |
18 |
Correct |
955 ms |
2504 KB |
Output is correct |
19 |
Correct |
951 ms |
2504 KB |
Output is correct |
20 |
Correct |
955 ms |
2500 KB |
Output is correct |
21 |
Correct |
961 ms |
2580 KB |
Output is correct |
22 |
Correct |
952 ms |
2584 KB |
Output is correct |
23 |
Correct |
957 ms |
2556 KB |
Output is correct |
24 |
Correct |
956 ms |
2644 KB |
Output is correct |
25 |
Correct |
968 ms |
2656 KB |
Output is correct |
26 |
Correct |
957 ms |
2656 KB |
Output is correct |
27 |
Correct |
953 ms |
2588 KB |
Output is correct |
28 |
Correct |
959 ms |
2576 KB |
Output is correct |
29 |
Correct |
955 ms |
2548 KB |
Output is correct |
30 |
Correct |
969 ms |
2396 KB |
Output is correct |
31 |
Correct |
965 ms |
2664 KB |
Output is correct |
32 |
Correct |
968 ms |
2608 KB |
Output is correct |
33 |
Correct |
958 ms |
2640 KB |
Output is correct |
34 |
Correct |
955 ms |
2644 KB |
Output is correct |
35 |
Correct |
955 ms |
2640 KB |
Output is correct |
36 |
Correct |
964 ms |
2640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
951 ms |
2504 KB |
Output is correct |
2 |
Correct |
952 ms |
2504 KB |
Output is correct |
3 |
Correct |
951 ms |
2504 KB |
Output is correct |
4 |
Correct |
951 ms |
2508 KB |
Output is correct |
5 |
Correct |
953 ms |
2644 KB |
Output is correct |
6 |
Correct |
951 ms |
2524 KB |
Output is correct |
7 |
Correct |
951 ms |
2644 KB |
Output is correct |
8 |
Correct |
951 ms |
2644 KB |
Output is correct |
9 |
Correct |
951 ms |
2500 KB |
Output is correct |
10 |
Correct |
955 ms |
2504 KB |
Output is correct |
11 |
Correct |
962 ms |
2520 KB |
Output is correct |
12 |
Correct |
954 ms |
2520 KB |
Output is correct |
13 |
Correct |
959 ms |
2640 KB |
Output is correct |
14 |
Correct |
959 ms |
2512 KB |
Output is correct |
15 |
Correct |
955 ms |
2396 KB |
Output is correct |
16 |
Correct |
951 ms |
2504 KB |
Output is correct |
17 |
Correct |
953 ms |
2644 KB |
Output is correct |
18 |
Correct |
955 ms |
2504 KB |
Output is correct |
19 |
Correct |
951 ms |
2504 KB |
Output is correct |
20 |
Correct |
955 ms |
2500 KB |
Output is correct |
21 |
Correct |
961 ms |
2580 KB |
Output is correct |
22 |
Correct |
952 ms |
2584 KB |
Output is correct |
23 |
Correct |
957 ms |
2556 KB |
Output is correct |
24 |
Correct |
956 ms |
2644 KB |
Output is correct |
25 |
Correct |
968 ms |
2656 KB |
Output is correct |
26 |
Correct |
957 ms |
2656 KB |
Output is correct |
27 |
Correct |
953 ms |
2588 KB |
Output is correct |
28 |
Correct |
959 ms |
2576 KB |
Output is correct |
29 |
Correct |
955 ms |
2548 KB |
Output is correct |
30 |
Correct |
969 ms |
2396 KB |
Output is correct |
31 |
Correct |
965 ms |
2664 KB |
Output is correct |
32 |
Correct |
968 ms |
2608 KB |
Output is correct |
33 |
Correct |
958 ms |
2640 KB |
Output is correct |
34 |
Correct |
955 ms |
2644 KB |
Output is correct |
35 |
Correct |
955 ms |
2640 KB |
Output is correct |
36 |
Correct |
964 ms |
2640 KB |
Output is correct |
37 |
Correct |
962 ms |
3156 KB |
Output is correct |
38 |
Correct |
951 ms |
2788 KB |
Output is correct |
39 |
Correct |
988 ms |
2504 KB |
Output is correct |
40 |
Correct |
956 ms |
3408 KB |
Output is correct |
41 |
Correct |
988 ms |
2756 KB |
Output is correct |
42 |
Correct |
994 ms |
3200 KB |
Output is correct |
43 |
Correct |
982 ms |
3920 KB |
Output is correct |
44 |
Execution timed out |
1002 ms |
3924 KB |
Time limit exceeded |
45 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
951 ms |
2504 KB |
Output is correct |
2 |
Correct |
952 ms |
2504 KB |
Output is correct |
3 |
Correct |
951 ms |
2504 KB |
Output is correct |
4 |
Correct |
951 ms |
2508 KB |
Output is correct |
5 |
Correct |
953 ms |
2644 KB |
Output is correct |
6 |
Correct |
951 ms |
2524 KB |
Output is correct |
7 |
Correct |
951 ms |
2644 KB |
Output is correct |
8 |
Correct |
951 ms |
2644 KB |
Output is correct |
9 |
Correct |
951 ms |
2500 KB |
Output is correct |
10 |
Correct |
955 ms |
2504 KB |
Output is correct |
11 |
Correct |
962 ms |
2520 KB |
Output is correct |
12 |
Correct |
954 ms |
2520 KB |
Output is correct |
13 |
Correct |
959 ms |
2640 KB |
Output is correct |
14 |
Correct |
959 ms |
2512 KB |
Output is correct |
15 |
Correct |
955 ms |
2396 KB |
Output is correct |
16 |
Correct |
951 ms |
2504 KB |
Output is correct |
17 |
Correct |
953 ms |
2644 KB |
Output is correct |
18 |
Correct |
955 ms |
2504 KB |
Output is correct |
19 |
Correct |
951 ms |
2504 KB |
Output is correct |
20 |
Correct |
955 ms |
2500 KB |
Output is correct |
21 |
Correct |
961 ms |
2580 KB |
Output is correct |
22 |
Correct |
952 ms |
2584 KB |
Output is correct |
23 |
Correct |
957 ms |
2556 KB |
Output is correct |
24 |
Correct |
956 ms |
2644 KB |
Output is correct |
25 |
Correct |
968 ms |
2656 KB |
Output is correct |
26 |
Correct |
957 ms |
2656 KB |
Output is correct |
27 |
Correct |
953 ms |
2588 KB |
Output is correct |
28 |
Correct |
959 ms |
2576 KB |
Output is correct |
29 |
Correct |
955 ms |
2548 KB |
Output is correct |
30 |
Correct |
969 ms |
2396 KB |
Output is correct |
31 |
Correct |
965 ms |
2664 KB |
Output is correct |
32 |
Correct |
968 ms |
2608 KB |
Output is correct |
33 |
Correct |
958 ms |
2640 KB |
Output is correct |
34 |
Correct |
955 ms |
2644 KB |
Output is correct |
35 |
Correct |
955 ms |
2640 KB |
Output is correct |
36 |
Correct |
964 ms |
2640 KB |
Output is correct |
37 |
Correct |
962 ms |
3156 KB |
Output is correct |
38 |
Correct |
951 ms |
2788 KB |
Output is correct |
39 |
Correct |
988 ms |
2504 KB |
Output is correct |
40 |
Correct |
956 ms |
3408 KB |
Output is correct |
41 |
Correct |
988 ms |
2756 KB |
Output is correct |
42 |
Correct |
994 ms |
3200 KB |
Output is correct |
43 |
Correct |
982 ms |
3920 KB |
Output is correct |
44 |
Execution timed out |
1002 ms |
3924 KB |
Time limit exceeded |
45 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
951 ms |
2504 KB |
Output is correct |
2 |
Correct |
952 ms |
2504 KB |
Output is correct |
3 |
Correct |
951 ms |
2504 KB |
Output is correct |
4 |
Correct |
951 ms |
2508 KB |
Output is correct |
5 |
Correct |
953 ms |
2644 KB |
Output is correct |
6 |
Correct |
951 ms |
2524 KB |
Output is correct |
7 |
Correct |
951 ms |
2644 KB |
Output is correct |
8 |
Correct |
951 ms |
2644 KB |
Output is correct |
9 |
Correct |
951 ms |
2500 KB |
Output is correct |
10 |
Correct |
955 ms |
2504 KB |
Output is correct |
11 |
Correct |
962 ms |
2520 KB |
Output is correct |
12 |
Correct |
954 ms |
2520 KB |
Output is correct |
13 |
Correct |
959 ms |
2640 KB |
Output is correct |
14 |
Correct |
959 ms |
2512 KB |
Output is correct |
15 |
Correct |
955 ms |
2396 KB |
Output is correct |
16 |
Correct |
951 ms |
2504 KB |
Output is correct |
17 |
Correct |
953 ms |
2644 KB |
Output is correct |
18 |
Correct |
955 ms |
2504 KB |
Output is correct |
19 |
Correct |
951 ms |
2504 KB |
Output is correct |
20 |
Correct |
955 ms |
2500 KB |
Output is correct |
21 |
Correct |
961 ms |
2580 KB |
Output is correct |
22 |
Correct |
952 ms |
2584 KB |
Output is correct |
23 |
Correct |
957 ms |
2556 KB |
Output is correct |
24 |
Correct |
956 ms |
2644 KB |
Output is correct |
25 |
Correct |
968 ms |
2656 KB |
Output is correct |
26 |
Correct |
957 ms |
2656 KB |
Output is correct |
27 |
Correct |
953 ms |
2588 KB |
Output is correct |
28 |
Correct |
959 ms |
2576 KB |
Output is correct |
29 |
Correct |
955 ms |
2548 KB |
Output is correct |
30 |
Correct |
969 ms |
2396 KB |
Output is correct |
31 |
Correct |
965 ms |
2664 KB |
Output is correct |
32 |
Correct |
968 ms |
2608 KB |
Output is correct |
33 |
Correct |
958 ms |
2640 KB |
Output is correct |
34 |
Correct |
955 ms |
2644 KB |
Output is correct |
35 |
Correct |
955 ms |
2640 KB |
Output is correct |
36 |
Correct |
964 ms |
2640 KB |
Output is correct |
37 |
Correct |
962 ms |
3156 KB |
Output is correct |
38 |
Correct |
951 ms |
2788 KB |
Output is correct |
39 |
Correct |
988 ms |
2504 KB |
Output is correct |
40 |
Correct |
956 ms |
3408 KB |
Output is correct |
41 |
Correct |
988 ms |
2756 KB |
Output is correct |
42 |
Correct |
994 ms |
3200 KB |
Output is correct |
43 |
Correct |
982 ms |
3920 KB |
Output is correct |
44 |
Execution timed out |
1002 ms |
3924 KB |
Time limit exceeded |
45 |
Halted |
0 ms |
0 KB |
- |