# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1105001 | KasymK | Kpart (eJOI21_kpart) | C++17 | 2055 ms | 444 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i)
#define wr puts("----------------")
template<class T>bool umin(T& a, T b) { return a > b ? a = b, 1 : 0; }
template<class T>bool umax(T& a, T b) { return a < b ? a = b, 1 : 0; }
bool is(deque<int> &dq){
int wow = accumulate(all(dq), 0);
if(wow&1)
return 0;
vector<bool> dp(wow+1, false);
dp[0] = 1;
for(int &to : dq)
for(int i = wow; i >= to; --i)
if(dp[i-to])
dp[i] = 1;
return dp[wow/2];
}
int main(){
int t;
scanf("%d", &t);
while(t--){
int n;
scanf("%d", &n);
vector<int> v(n+1);
for(int i = 1; i <= n; ++i){
int x;
scanf("%d", &x);
v[i] = x;
}
vector<int> A;
for(int k = 2; k <= n; ++k){
deque<int> dq;
bool ok = 1;
for(int i = 1; i <= k; ++i)
dq.pb(v[i]);
ok &= is(dq);
for(int i = k+1; i <= n; ++i){
dq.pb(v[i]);
dq.pop_front();
ok &= is(dq);
}
if(ok)
A.pb(k);
}
printf("%d ", (int)A.size());
tr(it, A)
printf("%d ", *it);
puts("");
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |