# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
612696 | karelisp | Kpart (eJOI21_kpart) | C++14 | 1383 ms | 324 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;
int T, N, a[1005], ps[1005];
int main(){
scanf("%d", &T);
while(T--){
scanf("%d", &N);
for(int i=1; i<=N; i++){
scanf("%d", &a[i]);
ps[i] = ps[i-1] + a[i];
}
vector<int> ans;
for(int K=2; K<=N; K++){
bitset<50005> sums;
sums[0] = true;
bool is_Kary = true;
for(int right=1; right<=N && is_Kary; right++){
sums |= sums<<a[right];
if(right<K)
continue;
int cur_sum = ps[right] - ps[right-K];
if(cur_sum%2 || sums[cur_sum/2]==false){
is_Kary = false;
}
sums &= sums>>a[right-K+1];
}
if(is_Kary)
ans.push_back(K);
}
printf("%ld ", ans.size());
for(auto K : ans) printf("%d ", K);
printf("\n");
}
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... |