이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cave.h"
void exploreCave(int N) {
int *correctPos = new int[N];
int *door = new int[N];
bool *stablePos = new bool[N];
for(int i = 0; i < N; i++)
{
correctPos[i] = 0;
door[i] = 0;
stablePos[i] = 0;
}
int currentPosition = 0;
for(int d = 0; d < N; d++)
{
int r = tryCombination(correctPos);
if(r != d)
{
currentPosition = 1 - currentPosition;
for(int i = 0; i < N; i++)
if(!stablePos[i])
correctPos[i] = 1 - correctPos[i];
}
///pozitia corecta pentru a deschide usa d este 1 - currentPosition
int *auxarr = new int[N];
for(int i = 0; i < N; i++)
auxarr[i] = 0;
int st = 0, dr = N - 1;
while(st < dr)
{
int mid = (st + dr) >> 1;
for(int i = 0; i < N; i++)
if(stablePos[i]) auxarr[i] = correctPos[i];
else if(st <= i && i <= mid) auxarr[i] = 1 - currentPosition;
else auxarr[i] = currentPosition;
r = tryCombination(auxarr);
if(r != d)
{
///pozitia corecta e in st...mid
dr = mid;
}
else
{
///pozitia corecta e in mid+1...dr
st = mid + 1;
}
}
stablePos[st] = 1;
correctPos[st] = 1 - currentPosition;
door[st] = d;
}
answer(correctPos, door);
delete[] correctPos;
delete[] door;
delete[] stablePos;
}
# | 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... |