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;
int n,cur;
int s[5001];
int d[5001];
bool vis[5001];
bool check(int x,int y)
{
for(int i=x;i<=y;i++)
{
if(vis[i])continue;
s[i]=!s[i];
}
int q=tryCombination(s);
for(int i=x;i<=y;i++)
{
if(vis[i])continue;
s[i]=!s[i];
}
if(q>cur || q==-1)return 1;
return 0;
}
void exploreCave(int N)
{
n=N;
for(int i=0;i<n;i++)
{
cur=i;
int q=tryCombination(s);
if(q>cur || cur==-1)
{
for(int j=0;j<n;j++)
{
if(vis[j])continue;
s[j]=!s[j];
}
}
int l=0;
int r=n-1;
int m;
while(l<r)
{
m=(l+r)/2;
if(check(l,m))
{
r=m;
}
else
{
l=m+1;
}
}
vis[r]=1;
d[i]=r;
s[r]=!s[r];
}
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... |