# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
385116 | Azimjon | 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 "cave.h"
#include <bits/stdc++.h>
using namespace std;
void exploreCave(int N)
{
int s[N], d[N];
memset(s, 0, sizeof(s));
memset(d, -1, sizeof(d));
vector<int> r;
for (int i = 0; i < N; i++)
{
r.push_back(tryCombination(s));
int l = 0, r = N - 1;
while (l < r) {
int m = (l + r) / 2;
for (int j = l; j <= m; j++) {
if (d[j] == -1) s[j] ^= 1;
}
r.push_back(tryCombination(s));
if ((r.back() == i) ^ (r[r.size() - 2] == i)) {
r = m;
} else {
l = m;
}
}
d[l] = i;
s[l] ^= 1;
}
answer(s, d);
}