# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
781059 | caganyanmaz | Cave (IOI13_cave) | C++17 | 562 ms | 516 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 <bits/stdc++.h>
using namespace std;
#include "cave.h"
constexpr static int MXSIZE = 5000;
int n;
int s[MXSIZE], d[MXSIZE]; // Result
int c[MXSIZE]; // For queries
bool is_visibly_open(int i, int result)
{
return result > i || result == -1;
}
void exploreCave(int N)
{
n = N;
for (int i = 0; i < n; i++)
d[i] = -1;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
c[j] = (d[j] == -1) ? 0 : s[j];
int correct = 1;
if (is_visibly_open(i, tryCombination(c)))
correct = 0;
int l = -1, r = n;
while (r - l > 1)
{
int m = l+r>>1;
for (int j = 0; j <= m; j++)
c[j] = (d[j] == -1) ? correct : s[j];
for (int j = m+1; j < n; j++)
c[j] = (d[j] == -1) ? (1 - correct) : s[j];
if (is_visibly_open(i, tryCombination(c)))
r = m;
else
l = m;
}
d[r] = i;
s[r] = correct;
}
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... |