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"
void exploreCave(int n)
{
int s[n], d[n];
for(int i = 0; i < n; i++)
{
s[i] = 0;
d[i] = -1;
}
int cur, prev, door;
for(int i = 0; i < n; i++)
{
door = tryCombination(s);
if(door > i || door == -1)
prev = 1;
else
prev = 0;
int low = 0, high = n;
while(high - low > 2)
{
int middle = (low + high) / 2;
for(int j = low; j <= middle; j++)
{
if(d[j] != -1) continue;
if(s[j]) s[j] = 0;
else s[j] = 1;
}
door = tryCombination(s);
if(door > i || door == -1)
cur = 1;
else
cur = 0;
if(cur == prev)
low = middle;
else
high = middle;
prev = cur;
}
if(s[low]) s[low] = 0;
else s[low] = 1;
door = tryCombination(s);
if(door > i || door == -1)
cur = 1;
else
cur = 0;
int ind;
if(cur == prev)
{
d[high] = i;
ind = high;
}
else
{
d[low] = i;
ind = low;
}
door = tryCombination(s);
if(door <= i)
{
if(s[ind]) s[ind] = 0;
else s[ind] = 1;
}
}
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... |