| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1287989 | eri16 | 동굴 (IOI13_cave) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;
void exploreCave(int n){
int d[n],v[n],fnd[n];
for (int i=0; i<n; i++){
v[i]=0;
fnd[i]=0;
}
int ans,cr1,cr2;
queue <int> q;
int tt=0;
int fns=0;
cr1=tryCombination(v);
for (int j=0; j<n; j++){
int l=0;
int r=n-1;
while(l!=r){
int md=(l+r)/2;
for(int i=l; i<=md; i++){if(fnd[i]==0){v[i]=1-v[i];}}
cr2=tryCombination(v);
if ((cr2!=j && cr1!=j) || cr2==cr1){l=min(r,md+1);}
else{r=md;}
cr1=cr2;
}
if (cr1==j){v[j]=1-v[j];}
fnd[j]=1;
d[l]=i;
cr1=tryCombination(v);
}
answer(v,d);
}
