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>
bool done[5005];
int get(int S[]) {
int ret = tryCombination(S);
if (ret == -1) ret = 5001;
return ret;
}
void exploreCave(int N) {
int s[N], d[N];
for (int i = 0; i < N; i++) {
int l = 0, r = N - 1;
// assume doors [0, i-1] are already open
bool state = get(s) == i;
while (l <= r) {
int m = (l + r) / 2;
for (int j = l; j <= m; j++)
if (!done[j]) s[j] = state;
int idx = get(s);
for (int j = l; j <= m; j++)
if (!done[j]) s[j] = 0;
if (idx == i) l = m + 1;
else r = m - 1;
}
s[l] = state;
d[l] = i;
done[l] = 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... |