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;
void solve() {
int n;
cin >> n;
vector<int> v(n+1), dp(100005), ans(n+1, 1), res;
for(int i=1; i<=n; i++) {
cin >> v[i];
int sum = 0; dp[v[i]] = i;
for(int j=100000; j>v[i]; j--) dp[j] = max(dp[j], dp[j-v[i]]);
for(int j=i; j>=1; j--) {
sum += v[j];
if(sum % 2 == 1 || dp[sum/2] < j) ans[i-j+1] = 0;
}
}
for(int i=1; i<=n; i++) if(ans[i]) res.push_back(i);
cout << res.size() << " ";
for(int &x : res) cout << x << " ";
cout << '\n';
}
int main() {
int t = 1; cin >> t;
while(t--) solve();
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... |