이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
int spos[5005], door[5005], ret;
bool cor[5005], prevdopen, dopen;
void exploreCave(int N) {
for (int i = 0; i < N; i++) door[i] = -1;
memset(cor, 0, sizeof cor); //All incorrect
ret = tryCombination(spos);
for (int i = 0; i < N; i++) { //Solve for each door
if (ret == -1 or ret > i) prevdopen = true;
else prevdopen = false;
int upper = N, lower = -1;
while (upper - lower > 1) {
int mid = (upper + lower) / 2;
for (int j = lower + 1; j <= mid; j++) {
if (cor[j]) continue;
spos[j] = !spos[j];
}
ret = tryCombination(spos);
if (ret == -1 or ret > i) dopen = true;
else dopen = false;
if (dopen == prevdopen) lower = mid; //Switch not in this half
else upper = mid;
prevdopen = dopen;
}
door[upper] = i;//Switch is upper
cor[upper] = true;
if (!dopen) { //Guessed which switch but position wrong
spos[upper] = !spos[upper];
ret = tryCombination(spos);
}
}
answer(spos, door);
}
# | 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... |