# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
890135 | kim | Kpart (eJOI21_kpart) | C++17 | 295 ms | 860 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define eb emplace_back
const int MX=100000;
int a[1005],qs[1005];
int dp[MX+5]={1};
void solve(){
int n; cin>>n;
for(int i=1;i<=n;++i){
cin>>a[i];
qs[i]=a[i]+qs[i-1];
}
for(int i=1;i<=MX;++i) dp[i]=0;
vector<bool> ok(n+5,1);
for(int i=1;i<=n;++i){
for(int j=MX-a[i];j>=0;--j) if(dp[j]) dp[j+a[i]]=1;
for(int j=1,k=i;j<i;++j,--k){
if((qs[i]-qs[j-1])&1) ok[k]=0;
if(!ok[k]) continue;
if(!dp[qs[i]+qs[j-1]>>1]) ok[k]=0;
}
}
vector<int> ans;
for(int i=2;i<=n;++i){
if(ok[i]) 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;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |