Submission #1280672

#TimeUsernameProblemLanguageResultExecution timeMemory
1280672kkkkkKpart (eJOI21_kpart)C++20
10 / 100
2095 ms572 KiB
#include <bits/stdc++.h>
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

Compilation message (stderr)

Main.cpp:5:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
    5 | const int inf = 1e18;
      |                 ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...