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]^=1;
}
int q=tryCombination(s);
for(int i=x;i<=y;i++)
{
if(vis[i])continue;
s[i]^=1;
}
if(q>cur || q==-1)return 1;
return 0;
}
void exploreCave(int N)
{
n=N;
memset(s,0,sizeof(s));
memset(vis,0,sizeof(vis));
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]^=1;
}
}
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[r]=i;
s[r]^=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... |