# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
99271 | long10024070 | Cave (IOI13_cave) | C++11 | 0 ms | 0 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.
#define Link "https://oj.uz/problem/view/IOI13_cave?fbclid=IwAR2HAQQWHxbplVnmFGboqMw4yr-N9sR3mRA2usvk6rTocr7u5QYaZIyHqxw"
#include <iostream>
#include <cstdio>
#define TASK "Cave"
using namespace std;
const int maxn = 5e3 + 10;
int n,Val[maxn];
bool s[maxn],True[maxn];
#include "cave.h"
void Fill(int l, int r, bool d)
{
for (int i=l;i<=r;++i)
if (Val[i] != -1)
s[i] = True[i];
else
s[i] = d;
}
void exploreCave(int n)
{
fill(Val,Val+n,-1);
for (int i=0;i<n;++i) {
Fill(0,n-1,0);
bool fl = (i == tryCombination(s));
int l = 0;
int r = n - 1;
while (l <= r) {
int m = (l + r) / 2;
Fill(1,n-1,fl^1);
Fill(l,m,fl);
Fill(m+1,r,fl^1);
if (tryCombination(s) == i)
l = m + 1;
else
r = m - 1;
}
True[l] = fl;
Val[l] = i;
}
answer(True,Val);
}