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 "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 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;
}
for(int i = 0; i < N; i++) { // door number
for(int j = 0; j < N; j++) { // switch number
if(open[j] != -1) {
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-1;
int mid = (low + high) / 2;
int answer = 3;
while ( low <= high) {
mid = (low + high) / 2;
for (int j = low; j <= mid; j++) {
if(open[j] != -1) {
S[j] = open[j];
}
S[j] = door[i];
}
for (int j = mid+1; j <= high; j++) {
if(open[j] != -1) {
S[j] = open[j];
}
S[j] = 1-door[i];
}
ans = tryCombination(S);
if(ans > i || ans == -1) {
answer = mid;
high = mid-1;
} else {
low = mid+1;
}
}
open[answer] = door[i];
target[answer] = 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... |