176002025-08-08 01:28:25peti1234K-részcpp17Accepted 100/100867ms1076 KiB
#include <bits/stdc++.h>
using namespace std;
const int c=100005;
int n, sum, t[c], pref[c], dp[c], rossz[c]; 
vector<int> ans;
void solve() {
    cin >> n;
    for (int i=1; i<=n; i++) {
        cin >> t[i];
        pref[i]=pref[i-1]+t[i];
        sum+=t[i];
    }

    for (int i=1; i<=n; i++) {
        dp[0]=i;
        for (int j=sum/2-t[i]; j>=0; j--) {
            dp[j+t[i]]=max(dp[j+t[i]], dp[j]);
        }
        for (int j=1; j<=i; j++) {
            int ert=pref[i]-pref[j-1], len=i-j+1;
            if (ert%2 || dp[ert/2]<j) rossz[len]=1;
        }
    }
    
    for (int i=1; i<=n; i++) {
        if (!rossz[i]) {
            ans.push_back(i);
        }
        rossz[i]=0;
    }

    cout << ans.size() << " ";
    for (auto x:ans) {
        cout << x << " ";
    }
    cout << "\n";

    ans.clear();
    for (int i=0; i<c; i++) dp[i]=0;
    sum=0;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int w;
    cin >> w;
    while (w--) {
        solve();
    }
}
SubtaskSumTestVerdictTimeMemory
subtask110/10
1Accepted2ms820 KiB
subtask220/20
1Accepted4ms820 KiB
2Accepted13ms820 KiB
subtask370/70
1Accepted48ms824 KiB
2Accepted130ms1004 KiB
3Accepted150ms1012 KiB
4Accepted272ms820 KiB
5Accepted615ms1076 KiB
6Accepted867ms816 KiB
7Accepted791ms852 KiB