Submission #888393

#TimeUsernameProblemLanguageResultExecution timeMemory
888393pccBootfall (IZhO17_bootfall)C++14
65 / 100
1066 ms4708 KiB
#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> 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; vector<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.push_back(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]; } relax((int)1e9+7); relax((int)712271227); relax((int)1e8+7); relax(113); relax(998244353); relax(101010111); /* 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...