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 <iostream>
#include <queue>
#include <algorithm>
//#include <fstream>
using namespace std;
//ifstream F("be.txt");
vector<int> ans, x, s;
int N;
const int maxN = 1e5;
void DP(int k){
vector<int> dp;
dp.push_back(0);
int sum = 0;
for(int i = k; i < N; ++i){
sum += x[i];
for(int j = dp.size() - 1; j >= 0; --j)
dp.push_back(dp[j] + x[i]);
sort(dp.begin(), dp.end());
//auto it = unique(dp.begin(), dp.end());
//dp.resize(distance(dp.begin(), it));
if(sum % 2 == 0 && binary_search(dp.begin(), dp.end(), sum / 2)) ++s[i - k + 1];
}
return;
}
int main(){
int T;
cin >> T;
while(T--){
ans.clear();
cin >> N;
x.assign(N, 0);
s.assign(N + 1, 0);
for(auto &e : x)
cin >> e;
for(int i = 0; i < N; ++i)
DP(i);
for(int i = 1; i <= N; ++i)
if(s[i] == N - i + 1) ans.push_back(i);
cout << ans.size() << ' ';
for(auto e : ans)
cout << e << ' ';
cout << '\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |