#include <iostream>
#include <vector>
using namespace std;
const int N = 1001;
int a[N];
void solve(){
int n;
cin >> n;
for (int i = 1; i <= n; ++i)
cin >> a[i];
vector<int> ans;
int sum = a[1], mx = a[1];
for (int i = 2; i <= n; ++i){
sum += a[i];
mx = max(mx, a[i]);
if (sum%2) continue;
//cout << "sum, i = " << sum << ' ' << i << '\n';
vector<bool> dp(sum+1, false);
dp[0] = true;
for (int j = 1; j <= i; ++j)
for (int val = mx; val >= a[j]; --val)
dp[val] = dp[val] | dp[val-a[j]];
if (dp[sum/2] == 1)
ans.push_back(i);
}
cout << ans.size() << ' ';
for (int i = 0; i < ans.size(); ++i)
cout << ans[i] << " \n"[i==ans.size()-1];
}
int main(){
ios::sync_with_stdio(false);
//cin.tie(NULL);
int tt;
cin >> tt;
while(tt--)
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... |