이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cave.h"
#include <cstdio>
#include <cstring>
void exploreCave(int N) {
int forced[N];
memset(forced,-1,sizeof(forced));
int conn[N];
int now[N];
for(int i = 0; i < N; i++){
for(int j = 0; j < N; j++){
if(forced[j] != -1) now[j] = forced[j];
else now[j] = 0;
}
int res = tryCombination(now);
if(res > i || res == -1){
int lo = 0;
int hi = N-1;
int mid;
while(lo < hi){
mid = (lo + hi)/2;
for(int j = 0; j <= mid; j++){
now[j] = 1;
if(forced[j] != -1) now[j] = forced[j];
}
for(int j = mid+1; j <= N; j++){
now[j] = 0;
if(forced[j] != -1) now[j] = forced[j];
}
res = tryCombination(now);
if(res == i){
hi = mid;
}else{
lo = mid+1;
}
}
forced[lo] = 0;
conn[lo] = i;
}else{
int lo = 0;
int hi = N-1;
int mid;
while(lo < hi){
mid = (lo + hi)/2;
for(int j = 0; j <= mid; j++){
now[j] = 1;
if(forced[j] != -1) now[j] = forced[j];
}
for(int j = mid+1; j <= N; j++){
now[j] = 0;
if(forced[j] != -1) now[j] = forced[j];
}
res = tryCombination(now);
if(res > i || res == -1){
hi = mid;
}else{
lo = mid+1;
}
}
forced[lo] = 1;
conn[lo] = i;
}
}
answer(forced, conn);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |