# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
474228 | MB2 | Cave (IOI13_cave) | C++14 | 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.
#include <grader.h>
#include <bits/stdc++.h>
using namespace std;
int c[5009], id[5009], t[5009];
void change(int l, int r)
{
for(int i=l; i<=r; i++)
{
if(t[i]==0)
{
c[i]^=1;
}
}
}
void exploreCave(int N)
{
for(int i=0; i<N; i++)
{
int l=0, r=N-1, K;
int f=tryCombination(c)==i;
while(r-l>=0)
{
int mid=(l + r)>>1;
change(l, mid);
if ((tryCombination(c)==i)==f)
{
change(l, mid);
l=mid+1;
} else
{
change(l, mid);
r=mid-1;
K=mid;
}
}
t[K]=1;
id[K]=i;
c[K]=f;
}
answer(c, id);
}