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"
#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... |