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];
memset(d,-1,sizeof d);
int s[n];
memset(s,0,sizeof s);
bool vis[n];
memset(vis,0,sizeof vis);
for(int i=0;i<n;i++)
{
for(int idx=0;idx<n;idx++)
{
if(vis[idx]==true)continue;
s[idx]=0;
}
int lastd=tryCombination(s);
int tip=0;
if(lastd==-1 || lastd>i+1)
{
tip=1;
}
int l=0;
int r=n-1;
while(l<r)
{
int mid=l+(r-l)/2;
for(int idx=0;idx<n;idx++)
{
if(vis[idx]==true)continue;
s[idx]=tip;
}
if(tip==1)
{
if(tryCombination(s)>i+1)
{
l=mid+1;
}
else
{
r=mid;
}
}
else
{
if(tryCombination(s)<=i+1)
{
l=mid+1;
}
else
{
r=mid;
}
}
}
vis[l]=true;
s[l]=(tip+1)%2;
d[i]=l+1;
}
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... |