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"
bool visited[5010] = { 0 };
int s[5010] = { 0 }, d[5010] = { 0 };
int check[5010] = { 0 };
int n;
void solve(int index, int l, int r, int swit)
{
if (l == r)
{
d[l] = index;
s[l] = swit;
visited[l] = 1;
return;
}
int mid = l + (r - l) / 2;
for (int i = 0; i < n; ++i)
{
if (visited[i])
check[i] = s[i];
else
check[i] = !swit;
}
for (int i = l; i <= mid; ++i)
{
if (!visited[i])
check[i] = swit;
}
int cur = tryCombination(check);
if (cur == -1 || cur > index)
solve(index, l, mid, swit);
else
solve(index, mid + 1, r, swit);
}
void exploreCave(int N) {
n = N;
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < n; ++j)
{
if (visited[j])
check[j] = s[j];
else
check[j] = 0;
}
int cur = tryCombination(check);
int key;
if (cur == -1 || cur > i)
key = 0;
else
key = 1;
solve(i, 0, n - 1, key);
}
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... |