#include "bits/stdc++.h"
#include "cave.h"
#define sz(x) (int)size(x)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const char nl = '\n';
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int N = 5000;
int d[N], s[N], q[N];
void exploreCave(int n) {
vector<int> door_switch(n);
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++)
q[j] = 0;
for (int j = 0; j < i; j++) {
int id = door_switch[j];
q[id] = s[id];
}
int pos = tryCombination(q);
int t = ((pos == -1 || pos > i) ? 0 : 1);
auto f = [&](auto f, int l, int r) -> int {
if (l == r) return l;
int m = (l + r) / 2;
for (int j = 0; j < n; j++)
q[j] = 1 - t;
for (int j = l; j <= m; j++)
q[j] = t;
for (int j = 0; j < i; j++) {
int id = door_switch[j];
q[id] = s[id];
}
int ppos = tryCombination(q);
if (ppos == -1 || ppos > i)
return f(f, l, m);
else
return f(f, m + 1, r);
};
door_switch[i] = f(f, 0, n - 1);
d[door_switch[i]] = i;
s[door_switch[i]] = t;
}
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... |