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 <cstdio>
void exploreCave(int N) {
int S[N], D[N];
for (int i = 0; i < N; ++i) S[i] = 0, D[i] = -1;
for (int i = 0; i < N; ++i) {
int l = 0, r = N - 1, pos = N;
int res = tryCombination(S);
if (res == -1) res = N + 1;
if (res > i) {
for (int j = 0; j < N; ++j) if (D[j] == -1) S[j] ^= 1;
}
while (l <= r) {
// printf("L = %d, R = %d", l, r);
int m = (l + r) >> 1;
for (int j = l; j <= m; ++j) if (D[j] == -1) S[j] ^= 1;
res = tryCombination(S);
if (res == -1) res = N + 1;
// printf("Res = %d\n", res);
if (res > i) {
// Door i is open
pos = m;
r = m;
if (l == r) break;
} else l = m + 1;
for (int j = l; j <= m; ++j) if (D[j] == -1) S[j] ^= 1;
}
D[pos] = i;
//printf("Switch %d is connected with door %d\n", pos, i);
}
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... |