이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cave.h"
int open[5005]; // index = switch number return = 1, 0 ( open value )
int target[5005]; // index = switch number return = door number
int S[5005]; // index == switch number return = 1, 0 ( open Value request)
int find[5005]; // index = door 번호 return = 1, 0 ( 1 == find, 0 == not find)
int door[5005]; // index = door 번호 return 1, 0 (1 == open, 0 == close);
void exploreCave(int N) {
for(int i =0; i < N; i++) {
open[i] = -1;
target[i] = -1;
find[i] = 0;
}
for(int i = 0; i < N; i++) { // door number
for(int j = 0; j < N; j++) { // switch number
if(find[j]) {
S[j] = open[j];
}
S[j] = 1;
}
int ans = tryCombination(S);
if (ans > i || ans == -1) door[i] = 1;
else door[i] = 0;
int low = 0;
int high = N;
int mid = (low + high) / 2;
while ( low != mid) {
for ( int j = low ; j < mid; j++) {
if(find[j]) {
S[j] = open[j];
}
S[j] = door[i];
}
for(int j = mid; j < high ; j++) {
if(find[j]) {
S[j] = open[j];
}
S[j] = 1-door[i];
}
ans = tryCombination(S);
if(ans > i || ans == -1) {
high = mid;
mid = (low + high) / 2;
} else {
low = mid;
mid = (low + high) / 2;
}
}
target[mid] = i;
open[mid] = door[i];
}
answer(open,target);
}
# | 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... |