# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1217593 | LeonidCuk | Cave (IOI13_cave) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;
void exploreCave(int n)
{
vector<bool>vis(n);
int res[n],res1[n];
for(int i=0;i<n;i++)
{
res[i]=0;
res1[i]=0;
}
int a,b;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(vis[j]==0)
{
res[j]=0;
}
}
a=tryCombination(res);
if(a==i)b=1;
else b=0;
int l=0,r=n-1;
while(l<r)
{
int m=(l+r)/2;
for(int j=0;j<n;j++)
{
if(vis[j])continue;
if(j<=m)res[j]=b;
else res[j]=(b+1)%2;
a=tryCombination(res);
if(a==i)l=m+1;
else r=m;
}
res[l]=b;
vis[l]=true;
res2[i]=l;
}
}
answer(res,res2);
}