이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "cave.h"
void exploreCave(int n) {
// ith switch connected to door d[i]
// door i connected to s[i]
// correct condition of switch i is cc[i]
int d[n], s[n], cc[n];
for (int i = 0; i < n; i++) {
// find door i answer
int c[n];
for (int j = 0; j < i; j++) c[s[j]] = cc[s[j]];
int res = tryCombination(c); assert(res >= i or res == -1);
int cond = (res > i or res == -1) ? 0 : 1;
int l = 0, r = n-1;
while (l < r) {
int mid = (l+r)/2;
for (int j = 0; j <= mid; j++) c[j] = cond;
for (int j = 0; j <= mid; j++) c[j] = cond^1;
for (int j = 0; j < i; j++) c[s[j]] = cc[s[j]];
int res = tryCombination(c); assert(res >= i or res == -1);
if (res > i or res == -1) r = mid;
else l = mid+1;
}
// switch l control door i
d[l] = i; s[i] = l; cc[l] = cond;
}
assert(tryCombination(cc) == -1);
answer(cc, 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... |