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;
void exploreCave(int N) {
int n=N, s[N], d[N], re[N], ans[N];
for (int i=0;i<N;i++){
bool is=0;
for (int j=0;j<n;j++)s[j]=0;
for (int j=0;j<i;j++)s[re[j]]=ans[re[j]];
if (tryCombination(s)==i)is=1;
else is=0;
int l=0, r=N-1;
while(l!=r){
int mid=(l+r)/2;
for (int j=l;j<=mid;j++)s[j]=1-s[j];
for (int j=0;j<i;j++)s[re[j]]=ans[re[j]];
if (tryCombination(s)==i){
if (is)l=mid+1;
else{
is=1;
r=mid;
}
}
else{
if (is){
is=0;
r=mid;
}
else l=mid+1;
}
}
d[l]=i;
re[i]=l;
if (is){
ans[l]=1-s[l];
}
else{
ans[l]=s[l];
}
}
answer(ans, 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... |