이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cave.h"
#include <vector>
using namespace std;
void exploreCave(int n) {
int s[n] = {}, d[n] = {};
bool answered[n] = {};
for (int door = 0; door < n; door++) {
for (int i = 0; i < n; i++) {
if (answered[i]) continue;
s[i] = 0;
}
if (tryCombination(s) == door) {
// [1]
int l = -1, r = n - 1;
while (r - l > 1) {
int mid = (l + r) / 2;
for (int i = 0; i < n; i++) {
if (answered[i]) continue;
if (i <= mid) s[i] = 1;
else s[i] = 0;
}
if (tryCombination(s) == door)
l = mid;
else
r = mid;
}
d[r] = door;
s[r] = 1;
answered[r] = true;
} else {
// [0]
int l = -1, r = n - 1;
while (r - l > 1) {
int mid = (l + r) / 2;
for (int i = 0; i < n; i++) {
if (answered[i]) continue;
if (i <= mid) s[i] = 0;
else s[i] = 1;
}
if (tryCombination(s) == door)
l = mid;
else
r = mid;
}
d[r] = door;
s[r] = 0;
answered[r] = true;
}
}
answer(s, d);
}
| # | 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... |