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++) {
int ct = tryCombination(val);
if (ct > i || !(~ct)) {
int l = 0, r = N - 1;
while (l < r) {
int mid = (l + r) >> 1;
for (int j = 0; j <= mid; j++) D[j] = 0;
for (int j = mid + 1; j < N; j++) D[j] = 1;
for (int j = 0; j < i; j++) D[pos[j]] = val[pos[j]];
int cval = tryCombination(D);
if (cval > i || !(~cval)) r = mid;
else l = mid + 1;
}
pos[i] = l; revpos[l] = i;
} else {
int l = 0, r = N - 1;
while (l < r) {
int mid = (l + r) >> 1;
for (int j = 0; j <= mid; j++) D[j] = 1;
for (int j = mid + 1; j < N; j++) D[j] = 0;
for (int j = 0; j < i; j++) D[pos[j]] = val[pos[j]];
int cval = tryCombination(D);
if (cval > i || !(~cval)) r = mid;
else l = mid + 1;
}
pos[i] = l; revpos[l] = i; val[l] = 1;
}
}
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... |