# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
585095 | Einsitein | Cave (IOI13_cave) | C++98 | 233 ms | 460 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;
namespace
{
} // namespace
void exploreCave(int N)
{
vector<int> s(N);
vector<int> d(N);
vector<int> guess(N, 0);
vector<bool> done(N, 0);
auto toggle = [&](int l, int r) -> void
{
for (int i = l; i < r; i++)
{
if (!done[i])
guess[i] ^= 1;
}
};
for (int i = 0; i < N; i++)
{
int lo = 0, hi = N;
bool last = (tryCombination(guess.data()) + N + 1) % (N + 1) > i;
while (hi - lo > 1)
{
int mid = (lo + hi) / 2;
toggle(lo, mid);
if (last != (tryCombination(guess.data()) + N + 1) % (N + 1) > i)
{
last = !last;
hi = mid;
}
else
lo = mid;
}
s[lo] = last ^ guess[lo] ^ 1;
d[lo] = i;
done[lo] = 1;
guess[lo] = s[lo];
}
answer(s.data(), d.data());
}
Compilation message (stderr)
# | 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... |