제출 #1280664

#제출 시각아이디문제언어결과실행 시간메모리
1280664kkkkkKpart (eJOI21_kpart)C++20
0 / 100
2095 ms572 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 l = 1, sum = 0, ok = 1;
            oh &= 0;
            oh[0] = 1;
            for(int r = 1; r <= n; r++){
                oh |= (oh << a[r]);
                sum += a[r];
                while(r - l + 1 > k){
                    sum -= a[l];
                    oh >>= a[l];
                    l++;
                }
                if(r - l + 1 == k && (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...