이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
void exploreCave(int N) {
int switchOfDoorXIsKnown[N];
int doorOfSwitchXIsKnown[N];
int posOfSwitch[N];
memset(switchOfDoorXIsKnown, -1, sizeof(switchOfDoorXIsKnown));
memset(doorOfSwitchXIsKnown, -1, sizeof(doorOfSwitchXIsKnown));
memset(posOfSwitch, -1, sizeof(posOfSwitch));
int toGuess[N];
for(int i = 0; i < N; i++) {
for(int j = 0; j < N; j++)
if(doorOfSwitchXIsKnown[j] == -1)
toGuess[j] = 0;
else
toGuess[j] = posOfSwitch[j];
bool offIsDown = tryCombination(toGuess) == i;
int lo = 0;
int hi = N-1;
while(lo != hi) {
int mid = (lo+hi)/2;
for(int j = 0; j < N; j++)
if(doorOfSwitchXIsKnown[j] == -1) {
if(j <= mid)
toGuess[j] = 0;
else
toGuess[j] = 1;
} else {
toGuess[j] = posOfSwitch[j];
}
if(offIsDown == (tryCombination(toGuess) == i))
hi = mid;
else
lo = mid+1;
}
switchOfDoorXIsKnown[i] = lo;
doorOfSwitchXIsKnown[lo] = i;
posOfSwitch[lo] = offIsDown;
}
answer(posOfSwitch, doorOfSwitchXIsKnown);
}
# | 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... |