# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
523677 | bebecanvas | Cave (IOI13_cave) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
void exploreCave(int N) {
int s[N];
int d[N];
for(int i=0; i<N; i++){d[i]=-1;}
for(int i=0; i<N; i++){
int l=0;
int r=N-1;
int test[N];
for(int i=0; i<N; i++){test[i]=0;}
for(int i=0; i<N; i++){if(d[i]!=-1){test[i]= s[i];}}
int lol= tryCombination(test);
while(l<=r){
int mid= l+(r-l)/2;
for(int j=mid; j<=r; j++){if(d[j]==-1){test[j]+= 1; test[j]%=2;}}
int loll= tryCombination(test);
if(lol==i){
if(loll>lol){
l= mid;
}else{
r= mid-1;
}
}else{
if(loll==i){
l= mid;
}else{
r= mid-1;
}
}
}
d[l]=i;
if(lol==i){s[l]=1;}else{s[l]=0;}
}
answer(s, d);
}