#include<bits/stdc++.h>
using namespace std;
int las[100005];
int main(){
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int a[n+1];
int pas[n+1];
for(int i=1; i<=n; i++){
cin>>a[i];
las[i]=-1;
pas[i]=1;
}
las[0]=0;
for(int i=1; i<=n; i++){
for(int j=50000; j>=0; j--){
las[j+a[i]]=max(las[j], las[j+a[i]]);
}
las[a[i]]=i;
int s=0;
for(int j=i; j>=1; j--){
s+=a[j];
if(s%2==1){
pas[i-j+1]=0;
// cout<<i-j+1<<endl;
continue;
}
if(las[s/2]<j){
pas[i-j+1]=0;
// cout<<i-j+1<<" "<<s<<" "<<i<<" "<<j<<" "<<las[s/2]<<endl;
}
}
// cout<<"i"<<i;
}
int p=0;
for(int i=2; i<=n; i++){
if(pas[i]==1){
p++;
// cout<<i<<" ";
}
}
cout<<p<<" ";
for(int i=2; i<=n; i++){
if(pas[i]==1){
// p++;
cout<<i<<" ";
}
}
cout<<endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
15 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
46 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
173 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |