Submission #1280668

#TimeUsernameProblemLanguageResultExecution timeMemory
1280668kkkkkKpart (eJOI21_kpart)C++20
10 / 100
2095 ms568 KiB
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N = 1e5 + 11;
const int inf = 1e18;
int a[N];

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int T = 1;
    cin >> T;

    while(T--){
        int n;
        cin >> n;
        for(int i = 1; i <= n; i++){
            cin >> a[i];
        }
        bitset < N > oh;
        vector < int > ans;
        for(int k = 1; k <= n; k++){
            int ok = 1;
            for(int r = k; r <= n; r++){
                oh &= 0;
                oh[0] = 1;
                int sum = 0;
                for(int i = r - k + 1; i <= r; i++){
                    sum += a[i];
                    oh |= (oh << a[i]);
                }
                if((oh[sum / 2] == 0 || sum&1)){
                    ok = 0;
                }
            }
            if(ok) ans.push_back(k);
        }
        cout << ans.size() << ' ';
        for(int i: ans) cout << i << ' ';
        cout << '\n';
    }    
}
// hello karim nurbakyt sanzhar azamat congratulation europa asia america laplas
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...