Submission #890119

#TimeUsernameProblemLanguageResultExecution timeMemory
890119kimKpart (eJOI21_kpart)C++17
30 / 100
2068 ms848 KiB
#include<bits/stdc++.h> using namespace std; using ll=long long; #define eb emplace_back const int MX=50000; int a[1005]; bool ok[1005][1005],flag[MX+5]; void solve(){ int n; cin>>n; for(int i=1;i<=n;++i){ cin>>a[i]; for(int j=i+1;j<=n;++j) ok[i][j]=0; } for(int i=1;i<n;++i){ if(a[i]>MX) continue; for(int j=1;j<=MX;++j) flag[j]=0; int sum=a[i]; flag[a[i]]=1; for(int j=i+1;j<=n;++j){ for(int k=min(sum,MX-a[j]);k>=1;--k) if(flag[k]) flag[k+a[j]]=1; sum+=a[j]; if(!(sum&1)&&flag[sum>>1]) ok[i][j]=1; } } vector<int> ans; for(int i=2;i<=n;++i){ bool ok2=1; for(int l=1,r=i;ok2&&r<=n;++l,++r){ if(!ok[l][r]) ok2=0; } if(ok2) ans.eb(i); } cout<<ans.size()<<" "; for(auto &e:ans) cout<<e<<" "; cout<<endl; } int main(){ ios::sync_with_stdio(false); cin.tie(0); int Q(1); cin>>Q; while(Q--){ solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...