#include <bits/stdc++.h>
#include "cave.h"
using namespace std;
void exploreCave(int N) {
int S[N], D[N];
bool used[N] = {false};
for (int door = 0; door < N; door++) {
int comb[N];
for (int i = 0; i < N; i++) {
comb[i] = used[i] ? S[i] : 0;
}
int l = 0, r = N - 1, switchIndex = -1;
while (l <= r) {
int mid = l + (r - l) / 2;
for (int i = 0; i < N; i++) {
comb[i] = used[i] ? S[i] : 0;
}
for (int i = l; i <= mid; i++) {
if (!used[i]) comb[i] = 1;
}
if (tryCombination(comb) == door || tryCombination(comb) == -1) {
switchIndex = mid;
l = mid + 1;
} else {
r = mid - 1;
}
}
comb[switchIndex] = 0;
if (tryCombination(comb) == door) {
comb[switchIndex] = 1;
}
D[switchIndex] = door;
S[switchIndex] = comb[switchIndex];
used[switchIndex] = 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... |