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>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
cin >> t;
while(t--){
int n;
cin >> n;
vector<int>v(n), res;
vector<vector<int>>good(n, vector<int>(n));
for(int i = 0;i < n;++i){
cin >> v[i];
}
bitset<100005>dp;
for(int i = 0;i < n;++i){
int sum = 0;
dp[0] = 1;
for(int j = i;j < n;++j){
dp |= (dp << v[j]);
sum += v[j];
good[i][j] = (sum % 2 == 0 && dp[sum / 2]);
}
dp.reset();
}
for(int l = 1;l <= n;++l){
bool flag = 1;
for(int i = 0;i + l - 1 < n;++i){
flag = (flag && good[i][i + l - 1]);
}
if(flag)res.push_back(l);
}
cout << (int)res.size() << " ";
for(int i : res){
cout << i << " ";
}
cout << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |