#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t, n, s;
cin >> t;
vector<int> a, lasti, pref;
set<int> k;
while (t--){
cin >> n;
a.assign(n+1, 0);
lasti.assign(50001, -1);
pref.assign(n+1, 0);
k.clear();
s = 0;
for (int i=1; i<n+1; i++){
cin >> a[i];
s += a[i];
pref[i] = s;
}
s /= 2;
for (int i=1; i<n+1; i++){
k.insert(i);
for (int j=s-a[i]; j>0; j--){
lasti[j + a[i]] = max(lasti[j + a[i]], lasti[j]);
}
if (a[i] <= s){
lasti[a[i]] = i;
}
for (int x : k){
if ((pref[i] - pref[i - x]) % 2 || lasti[(pref[i] - pref[i - x]) / 2] < i - x + 1){
cerr << x << " " << i << " " << (pref[i] - pref[i - x]) % 2 << "\n";
k.erase(x);
}
}
}
cout << k.size() << " ";
for (int x : k){
cout << x << " ";
}
cout << "\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
852 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
852 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
852 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |