# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1058646 | Nickpapadak | Kpart (eJOI21_kpart) | C++14 | 56 ms | 348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
// }
int suba[k+2], subap[k+2];
subap[0] = 0;
for(int j= 1; j<= k; ++j){
suba[j] = a[j+i-1];
}
sort(suba+1, suba+k+1);
for(int j=1; j<=k; ++j) subap[j] = subap[j-1] + suba[j];
ok = false;
for(int j = 1; j<= k; ++j){
for(int l = j; l <= k; ++l){
if(subap[l]-subap[j-1] == (sm>>1)) ok = true;
// if(k==6) printf("%d %d:%d %d\n",l,j ,subap[l]-subap[j-1], (sm>>1));
if(subap[l]-subap[j-1] > (sm>>1)) break;
}
}
if(!ok) break;
// if(prev.count((sm>>1)) == 0){
// ok = false;
// break;
// }
}
if(ok) ans.push(k);
}
// printf("\n");
printf("%ld", ans.size());
while(!(ans.empty())){
printf(" %d", ans.front());ans.pop();
}
printf("\n");
}
}
int main(){
scanf("%d", &T);
BruteForce();
return 0;
}
컴파일 시 표준 에러 (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... |