제출 #1280687

#제출 시각아이디문제언어결과실행 시간메모리
1280687kkkkkKpart (eJOI21_kpart)C++20
0 / 100
2053 ms572 KiB
#include <bits/stdc++.h>
using namespace std;

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

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

    int T = 1;
    cin >> T;

    bitset < N > oh;
    while(T--){
        int n;
        cin >> n;
        for(int i = 1; i <= n; i++){
            cin >> a[i];
        }
        vector < int > ans;
        for(int k = 1; k <= n; k++){
            int ok = 1, l = 1, sum = 0;
            oh = 0;
            oh[0] = 1;
            for(int r = 1; r <= n; r++){
                if(r - l + 1 > k){
                    sum -= a[l];
                    oh >>= a[l];
                    l++;
                }
                sum += a[r];
                oh |= (oh << a[r]);
                if(k <= r && (sum % 2 == 1 || oh[sum / 2] == 0)) {
                    ok = 0;
                    break;
                }
            }
            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...