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"
const int N = 5000;
int s[N];
int d [N];
bool skip [N];
int n;
void change(int to)
{
for (int i = 0; i <= to; i++)
{
if (!skip[i])
{
s[i] = !s[i];
}
}
}
int bs(bool org, int i)
{
int a = 0;
int b = n - 1;
int res = -1;
while (a <= b)
{
int mid = (a + b) / 2;
change(mid);
bool cgood = false;
int cur = tryCombination(s);
if (cur == - 1 || cur > i) cgood = true;
if (cgood != org)
{
res = mid;
b = mid - 1;
} else
{
a = mid + 1;
}
change(mid);
}
return res;
}
void exploreCave(int N) {
n = N;
for (int i = 0; i < n; i++)
{
int cur = tryCombination(s);
bool good = false;
if (cur == -1 || cur > i) good = true;
int ind = bs(good, i);
skip[ind] = true;
if (!good) s[ind] = !s[ind];
d[ind] = i;
}
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... |