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 "grader.c"
#include <vector>
using namespace std;
void FillWithZero(vector<int> &a, vector<int> &used, int l, int r, bool flag)
{
for (int i = l; i <= r; i++)
{
if (used[i] != -1)
a[i] = used[i];
else
a[i] = flag;
}
for (int i = 0; i < l; i++)
{
if (used[i] != -1)
a[i] = used[i];
else
a[i] = -1;
}
for (int i = r + 1; i < (int)a.size(); i++)
{
if (used[i] != -1)
a[i] = used[i];
else
a[i] = -1;
}
}
void exploreCave(int n)
{
vector<int> a(n), used(n, -1);
int ra[n], k, d[n];
for (int j = 0; j < n; j++)
{
int l = 0, r = n - 1;
bool flag = 0;
while (l < r)
{
int m = (l + r) >> 1;
FillWithZero(a, used, l, m, flag);
for (int i = 0; i < n; i++)
ra[i] = a[i];
k = tryCombination(ra);
if (k == j)
{
if (flag)
{
l = m + 1;
continue;
}
FillWithZero(a, used, m + 1, r, flag);
for (int i = 0; i < n; i++)
ra[i] = a[i];
k = tryCombination(ra);
if (k == j)
flag = 1;
else
l = m + 1;
}
else
r = m;
}
d[l] = j;
used[l] = flag;
}
for (int i = 0; i < n; i++)
ra[i] = used[i];
answer(ra, 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... |