# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
662819 | Alma | Cave (IOI13_cave) | C++17 | 0 ms | 0 KiB |
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"
void exploreCave(int N) {
memset(S, 0, sizeof S);
memset(D, -1, sizeof D);
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (D[j] != -1) {
A[j] = S[D[j]];
} else {
A[j] = 1;
}
}
int ret = tryCombination(A);
int target;
if (ret == i) {
target = 0;
} else {
target = 1;
}
int lo = 0, mid, res = -1, hi = N-1;
while (lo <= hi) {
mid = (lo+hi) / 2;
for (int j = 0; j < N; j++) {
if (D[j] != -1) continue;
if (j < mid) {
A[j] = target;
} else {
A[j] = 1 - target;
}
}
ret = tryCombination(A);
if (ret == i) {
lo = mid+1;
} else {
res = mid;
hi = mid-1;
}
}
S[i] = target;
D[i] = res;
}
answer(S, D);
}