제출 #763961

#제출 시각아이디문제언어결과실행 시간메모리
763961CookieKpart (eJOI21_kpart)C++14
10 / 100
2077 ms384 KiB
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
ifstream fin("VNOICUP.INP");
ofstream fout("VNOICUP.OUT");
#define sz(a) (int)a.size()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const ld PI = 3.14159265359;
using u128 = __uint128_t;
const int mxn = 1e5 + 5, mxv = 1e5 + 5;
int a[mxn + 1], n;
signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tt; cin >> tt;
    while(tt--){
        cin >> n;
        bitset<mxv>bs;

        for(int i = 1; i <= n; i++)cin >> a[i];
        vt<int>res;
        for(int len = 1; len <= n; len++){
            bool ok = 1;
            for(int j = 1; j + len - 1 <= n; j++){
                bs.reset(); int sm = 0; bs[0] = 1;
                for(int k = j; k <= j + len - 1; k++){
                    bs = bs | (bs << a[k]); sm += a[k];
                }
                if((sm & 1) || !bs[sm / 2]){
                    ok = 0; break;
                }
            }
            if(ok)res.pb(len);
        }
        cout << sz(res) << " ";
        for(auto i: res)cout << i << " ";
        cout << "\n";
    }

    return(0);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...