#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
const int logn=25;
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
int n;
while(t--)
{
cin>>n;
int x[n+1];
int p[n+1];
p[0]=0;
for(int i=1;i<=n;i++)
{
cin>>x[i];
p[i]=p[i-1]+x[i];
}
vector<int>ans;
for(int k=2;k<=n;k++)
{
bool ok=true;
for(int i=1;i<=n-k+1;i++)
{
int kol=(p[k+i-1]-p[i-1]);
if(kol%2==1)
{
ok=false;
break;
}
kol/=2;
set<int>prev;
prev.insert(0);
set<int>next;
for(int j=i;j<=i+k-1;j++)
{
for(auto ax:prev)
{
next.insert(ax+x[j]);
}
prev=next;
}
if(prev.count(kol)==0)
{
ok=false;
break;
}
}
if(ok)
{
ans.push_back(k);
}
}
cout<<ans.size()<<" ";
for(auto ax:ans)
{
cout<<ax<< " ";
}
cout<<endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
317 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2067 ms |
852 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2081 ms |
700 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |