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>
void exploreCave(int n) {
using namespace std;
vector<int> s(n), d(n, -1), query(n), unknown(n);
iota(unknown.begin(), unknown.end(), 0);
auto solve = [&](int door_id) {
const auto res_if_0 {tryCombination(query.data()) == door_id};
// const auto lo {unknown.begin()}, hi{unknown.end()};
int lo {}, hi {static_cast<int>(unknown.size()) - 1};
while (lo != hi) {
const auto mid {(lo + hi) >> 1};
for (int i = lo; i < mid; ++i) {
query[unknown[i]] = 1;
}
const auto res {tryCombination(query.data()) == door_id};
for (int i = lo; i < mid; ++i) {
query[unknown[i]] = 0;
}
res == res_if_0 ? lo = mid + 1 : hi = mid;
}
s[lo] = res_if_0;
d[lo] = door_id;
};
for (int i = 0; i < n; ++i) {
solve(i);
}
answer(s.data(), d.data());
}
# | 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... |