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 <bits/stdc++.h>
#include "cave.h"
using namespace std;
const int MX = 5000;
int S[MX], D[MX], A[MX];
void exploreCave(int N) {
memset(S, 0, sizeof S);
memset(D, -1, sizeof D);
for (int n = 0; n < N; n++) {
for (int i = 0; i < N; i++) {
if (D[i] != -1) {
A[i] = S[D[i]];
} else {
A[i] = 1;
}
}
int ret = tryCombination(A);
int target;
if (ret == n) {
target = 0;
} else {
target = 1;
}
int lo = 0, mid, res = 0, hi = N-1;
while (lo <= hi) {
mid = (lo+hi) / 2;
for (int i = 0; i < N; i++) {
if (D[i] != -1) continue;
if (i <= mid) {
A[i] = target;
} else {
A[i] = 1 - target;
}
}
ret = tryCombination(A);
if (ret == n) {
lo = mid+1;
} else {
res = mid;
hi = mid-1;
}
}
S[n] = target;
D[res] = n;
}
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... |