#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;
for(int j=100000; j>=v[i]; j--) dp[j] = max(dp[j], dp[j-v[i]]);
dp[v[i]] = 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 |
1 |
Correct |
36 ms |
976 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
105 ms |
1236 KB |
Output is correct |
2 |
Correct |
207 ms |
1236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
424 ms |
1204 KB |
Output is correct |
2 |
Correct |
719 ms |
816 KB |
Output is correct |
3 |
Correct |
756 ms |
920 KB |
Output is correct |
4 |
Correct |
1028 ms |
832 KB |
Output is correct |
5 |
Correct |
1475 ms |
984 KB |
Output is correct |
6 |
Correct |
1844 ms |
1244 KB |
Output is correct |
7 |
Correct |
1742 ms |
1124 KB |
Output is correct |