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<iostream>
const int maxN=5e3+1;
int n;
int S[maxN],D[maxN];
void solve(int x){
for(int i=0;i<n;i++){
if(D[i]==-1) S[i]=0;
}
int ans=tryCombination(S);
if(ans==x){
int l=0,r=n-1;
while(r>l){
int mid=(l+r)/2;
for(int j=0;j<=mid;j++){
if(D[j]==-1) S[j]=1;
}
if(tryCombination(S)==x+1) r=mid;
else l=mid+1;
for(int j=0;j<=mid;j++){
if(D[j]==-1) S[j]=0;
}
}
D[l]=x;
S[l]=0;
return;
}
int l=0,r=n-1;
while(r>l){
int mid=(l+r)/2;
for(int j=0;j<=mid;j++){
if(D[j]==-1) S[j]=1;
}
if(tryCombination(S)==x) r=mid;
else l=mid+1;
for(int j=0;j<=mid;j++){
if(D[j]==-1) S[j]=0;
}
}
D[l]=x;
S[l]=1;
}
void exploreCave(int N) {
n=N;
for(int i=0;i<n;i++) D[i]=-1,S[i]=-1;
for(int i=0;i<n;i++){
solve(i);
}
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... |