# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
969775 | elotelo966 | Cave (IOI13_cave) | C++17 | 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.
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;
#define lim 5005
int arr[lim],arr_use[lim];
bool kesin[lim];
inline void change(int l,int kac,int val){
int cur=l;
kac-=l;
kac++;
while(kac){
if(kesin[cur]){
cur++;
}
else{
kac--;
arr_use[cur]=val;
}
}
}
void exploreCave(int N) {
int n=N;
int ans[n],ans2[n];
for(int i=0;i<n;i++){
int door=tryCombination(arr);
if(door!=i)ans[i]=0; //cevap 0da
else ans[i]=1; // cevap 1de
int l=0,r=n-i-1;
while(l<=r){
int m=(l+r)/2;
change(l,m,ans[i]^1);
int door_use=tryCombination(arr_use);
if(door_use!=i)l=m+1;
else r=m-1;
}
ans2[i]=r;
kesin[i]=1;
arr[r]=ans[i];
arr_use=arr;
}
answer(ans,ans2);
return ;
}