# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
629389 | Stavab | Cave (IOI13_cave) | C++14 | 79 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"
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 > 1)
{
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(d[low] == -1)
{
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);
}
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... |