Submission #763965

#TimeUsernameProblemLanguageResultExecution timeMemory
763965CookieKpart (eJOI21_kpart)C++14
30 / 100
2061 ms472 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 = 5e4 + 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; vt<bool>ok(n + 1, 1); for(int i = 1; i <= n; i++)cin >> a[i]; bitset<mxv>bs; for(int i = 1; i <= n; i++){ bs.reset(); bs[0] = 1; int sm = 0; for(int j = i; j <= n; j++){ bs = bs | (bs << a[j]);sm += a[j]; if(sm & 1 || !bs[sm / 2]){ ok[j - i + 1] = 0; } } } vt<int>res; for(int i = 1; i <= n; i++){ if(ok[i])res.pb(i); } 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...