이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |