# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
835015 | AndrijaM | 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 <bits/stdc++.h>
#include "cave.h"
using namespace std;
const long long mod=1e9+7;
const long long maxn=2e5+10;
const long long logn=20;
long long di[8]={-1,-1,0,1,1,1,0,-1};
long long dj[8]={0,1,1,1,0,-1,-1,-1};
void exploreCave(int n)
{
vector<int>a(n,1);
vector<int>s(n,1);
bool vis[n];
memset(vis,0,sizeof vis);
vector<int>d(n);
int pr=-1;
for(int i=0;i<n;i++)
{
a=s;
int p=tryCombination(a);
if(p==pr)
{
int sw=0;
int l=0;
int r=n;
while(l<r)
{
int mid=l+(r-l)/2;
a=s;
for(int idx=mid;idx<n;idx++)
{
if(!vis[idx])
{
a[idx]=sw;
}
}
int pom=tryCombination(a);
if(pom>p)
{
l=mid+1;
}
else
{
r=mid;
}
}
vis[l]=1;
s[l]=sw;
d[i]=l;
}
else
{
int sw=1;
int l=0;
int r=n;
while(l<r)
{
int mid=l+(r-l)/2;
a=s;
for(int idx=mid;idx<n;idx++)
{
if(!vis[idx])
{
a[idx]=sw;
}
}
int pom=tryCombination(a);
if(pom>p)
{
l=mid+1;
}
else
{
r=mid;
}
}
vis[l]=1;
s[l]=sw;
d[i]=l;
}
}
answer(s,d);
}