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 s(n, -1), d(n, -1), vec(n, 0);
auto solve = [&](int door_id) {
// determine [start, n)
transform(s.begin(), s.end(), vec.begin(), [&](const auto& x) {
return x == -1 ? 0 : x;
});
const int correct {tryCombination(vec.data()) == door_id};
const auto wrong = !correct;
// auto interval {views::iota(0, n) | views::filter([&](const auto& i) { return s[i] == -1; })};
int lo = 0, hi = n - door_id;
while (lo != hi) {
const auto mid = (lo + hi) >> 1;
int id = 0;
for (int i = 0; i < n; ++i) {
if (s[i] != -1) continue;
vec[i] = id++ < mid ? correct : wrong;
}
// for (const auto& x : interval | views::take(mid)) {
// vec[x] = correct;
// }
// for (const auto& x : interval | views::drop(mid)) {
// vec[x] = wrong;
// }
tryCombination(vec.data()) == door_id ? hi = mid : lo = mid + 1;
}
s[lo] = correct;
d[lo] = door_id;
};
for (int i = 0; i < n; ++i) {
solve(i);
}
// for (const auto& i : views::iota(0, n)) {
// solve(i);
// }
}
# | 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... |