# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1125575 | imarn | Kpart (eJOI21_kpart) | C11 | 0 ms | 0 KiB |
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define plx pair<ll,int>
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vvi vector<vi>
#define pp pair<ll,int>
#define ub(x,i) upper_bound(all(x),i)-x.begin()
using namespace std;
const int mxn=5e4+5;
int dp[mxn];
int a[1005]{0};
int qs[1005]{0};
void solve(){
int n;cin>>n;
for(int i=1;i<=n;i++)cin>>a[i],qs[i]=qs[i-1]+a[i];
int nw=0,pv=0;
bool vis[n+1]={0};
int cnt=n-1;memset(dp,0,sizeof dp);
for(int i=1;i<=n;i++){
for(int j=mxn-1;j>=a[i]+1;j--){
dp[j]=max(dp[j],dp[j-a[i]]);
}dp[a[i]]=i;
for(int j=2;j<=i;j++){
if(vis[j])continue;
int rs=qs[i]-qs[i-j];
if(rs&1)vis[j]=1,cnt--;
if(dp[rs/2]<i-j+1)vis[j]=1,cnt--;
}
}
cout<<cnt<<' ';
for(int i=2;i<=n;i++)if(!vis[i])cout<<i<<' ';cout<<'\n';
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int t;cin>>t;while(t--)solve();
}