# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
305190 | Temmie | Cave (IOI13_cave) | C++17 | 0 ms | 0 KiB |
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 <bits/stdc++.h>
#include "cave.h"
void exploreCave(int n) {
std::vector <int> a(n), b(n), ans(n), vis(n, 0);
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) if (!vis[j]) a[j] = 0;
int cur = tryCombination(a);
int now = cur == -1 || cur > i ? 0 : 1;
int l = 0, r = n - 1;
while (l <= r) {
int mid = (l + r) >> 1;
for (int j = 0; j < n; j++) if (!vis[j]) a[j] = j <= mid ? now : 1 - now;
int comp = tryCombination(a);
if (comp == -1 || comp > i) b[i] = mid, r = mid - 1;
else l = mid + 1;
}
a[b[i]] = now;
vis[b[i]] = 69;
ans[b[i]] = i;
}
answer(a, ans);
}