# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1058567 | Nickpapadak | Kpart (eJOI21_kpart) | C++14 | 2062 ms | 1016 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;
void BruteForce(){
while(T--){
int N;
scanf("%d", &N);
int a[N+2], p[N+2];
p[0] = 0;
for(int i = 1; i<=N;++i){
scanf("%d", &a[i]);
p[i] = p[i-1] + a[i];
}
queue<int> ans;
for(int k = 2; k<= N; ++k){
bool ok = true;
for(int i = 1; i+k-1 <= N;++i){
int sm = (p[i+k-1]-p[i-1]);
if(sm % 2 == 1){
ok = false;
break;
}
set<int> prev;
prev.insert(0);
set<int> next;
for(int j = i; j<= i+k-1; ++j){
for(int num: prev){
next.insert(num+a[j]);
}
prev = next;
}
if(prev.count((sm>>1)) == 0){
ok = false;
break;
}
}
if(ok) ans.push(k);
}
printf("%ld", ans.size());
while(!(ans.empty())){
printf(" %d", ans.front());ans.pop();
}
printf("\n");
}
}
int main(){
scanf("%d", &T);
BruteForce();
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... |