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;
int T,N,A[1005], sum[1005], dp[1005][100005];
vector<int> ans;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> T;
    while (T--) {
        cin >> N;
        sum[0] = 0;
        for (int i = 1; i <= N; ++i) {
            cin >> A[i];
            sum[i] = sum[i-1] + A[i];
        }
        memset(dp,0,sizeof(dp));
        dp[0][0] = 1;
        for (int i = 1; i <= N; ++i) for (int j = 0; A[i]+j <= 100000; ++j) if (dp[i-1][j]) dp[i][j] += dp[i-1][j], dp[i][A[i]+j] += dp[i-1][j];
        for (int i = 1; i <= N; ++i) {
            bool can = true;
            for (int j = 1; i+j-1 <= N && can; ++j) {
                int total = sum[i+j-1] - sum[j-1];
                if (total % 2 != 0 || dp[i+j-1][total/2] == dp[j-1][total/2]) can = false;
            }
            if (can) ans.push_back(i);
        }
        cout << ans.size();
        for (int x: ans) cout << ' ' << x;
        cout << '\n';
        ans.clear();
    }
    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... |