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<bits/stdc++.h>
using namespace std;
void exploreCave(int N) {
int D[N] = {}, val[N] = {}, pos[N] = {}, revpos[N] = {};
for (int i = 0; i < N; i++) D[i] = val[i] = 0;
for (int i = 0; i < N; i++) {
auto apply = [&] (int idx, int st) {
for (int j = 0; j <= idx; j++) D[j] = st;
for (int j = idx + 1; j < N; j++) D[j] = !st;
for (int j = 0; j < i; j++) D[pos[j]] = val[pos[j]];
};
auto get = [&] (int x) {
int l = 0, r = N - 1;
while (l < r) {
int mid = (l + r) >> 1;
apply(mid, x);
int cval = tryCombination(D);
if (cval > i || !(~cval)) r = mid;
else l = mid + 1;
}
pos[i] = l; revpos[l] = i; val[l] = x;
};
int ct = tryCombination(val);
get(!(ct > i || !(~ct)));
}
answer(val, revpos);
}
# | 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... |