#include<bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef long double ld;
const ll INF = 1000000000000000007, DIM = 100007, DIM2 = 107, MAXN = 100007, MOD = 1000000007;
ll tt, mid, res,f, y, type, a[DIM], dp[DIM2][DIM], pref[DIM], ptr, root, cnt, sum, pos, h, p, sx,sy, id, testcase, curans, nn, split, n, m, x, k1, k2, changecnt,k,l,r,v,u, l1,r1,l2,r2;
bool flag, flag2;
char c;
vector<ll> ans;
void solve() {
ans.clear();
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];pref[i]=pref[i-1]+a[i];
}
for(int i=2;i<=n;i++){
flag=1;
for(int ii=1;ii<=n-i+1;ii++) {
if((pref[ii+i-1]-pref[ii-1])%2){flag=0;break;}
sum=0;
memset(dp[ii-1],0,sizeof(dp[ii-1]));
dp[ii-1][0]=1;
for(int j=ii;j<=ii+i-1;j++) {
sum+=a[j];
for(int k=0;k<=sum;k++) {
dp[j][k]=0;
dp[j][k]=dp[j-1][k];
if(k>=a[j]) dp[j][k]=max(dp[j][k],dp[j-1][k-a[j]]);
}
}
if(!dp[ii+i-1][sum/2]){flag=0;break;}
}
if(flag)ans.push_back(i);
}
cout<<ans.size()<<' ';
for(auto u : ans)cout<<u<<" ";
cout<<'\n';
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
tt=1;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
cin>>tt;
while(tt--) {
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
84 ms |
18516 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1376 ms |
49224 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
97 ms |
153164 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |