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>
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
using namespace std;
const int N=2e5+5;
const int inf=1e9;
const int mod=1e9+7;
const int N1=1e6+1;
vector<int>v;
vector<int>v1;
struct edge{
int v,time;
};
int dp[1001];
signed main(){
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
int t;
cin>>t;
while(t--){
int n;
cin>>n;
v.push_back(0);
for(int i=0;i<n;i++){
int x;
cin>>x;
v.push_back(x);
}
for(int l=1;l<=n;l++){
int sum=0;
for(int r=l;r<=n;r++){
sum+=v[r];
v1.push_back(v[r]);
if(dp[r-l+1]==1){
continue;
}
if(r-l+1>1){
if(sum%2==1){
dp[r-l+1]=1;
continue;
}
int cnt=sum/2;
sort(v1.begin(),v1.end());
for(int i=v1.size()-1;i>=0;i--){
if(cnt>=v1[i]){
cnt-=v1[i];
}
}
if(cnt!=0){
dp[r-l+1]=1;
}
}
}
v1.clear();
}
int ans=0;
for(int i=2;i<=n;i++){
if(dp[i]==0){
ans++;
}
}
cout<<ans<<" ";
for(int i=2;i<=n;i++){
if(dp[i]==0){
cout<<i<<" ";
}
dp[i]=0;
}
cout<<"\n";
v.clear();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |