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 "cave.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5+10;
void exploreCave(int n)
{
int d[n];
int s[n];
bool vis[n];
memset(d,-1,sizeof d);
memset(vis,0,sizeof vis);
memset(s,0,sizeof s);
for(int idx=0;idx<n;idx++)
{
for(int i=0;i<n;i++)
{
if(vis[i])continue;
s[i]=0;
}
int p=tryCombination(s);
int tip=-1;
if(p==idx)
{
tip=1;
}
else
{
tip=0;
}
int l=0;
int r=n-1;
while(true)
{
int mid=l+(r-l)/2;
if(tip==1)
{
for(int i=0;i<n;i++)
{
if(vis[i])continue;
s[i]=0;
}
for(int i=l;i<=mid;i++)
{
if(vis[i])continue;
s[i]=1;
}
}
else
{
for(int i=0;i<n;i++)
{
if(vis[i])continue;
s[i]=1;
}
for(int i=l;i<=mid;i++)
{
if(vis[i])continue;
s[i]=0;
}
}
int poz=tryCombination(s);
if(poz==idx)
{
l=mid+1;
}
else
{
r=mid;
}
if(l==r)break;
}
d[idx]=l;
s[l]=tip;
vis[l]=true;
}
answer(s,d);
}
# | 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... |