# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
985335 | user736482 | 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;
int match[5000],sent[5000];
bool openstate,fixed_[5000];
int ak;
void change(int a, int b, int c){
for(int i=a;i<=b;i++){
if(!fixed_[i])
sent[i]= c;
}
}
void exploreCave(int n){
for(int i=0;i<n;i++){
change(0,4999,1);
ak = tryCombination(sent);
if(ak!=i){
openstate=1;
}
else{
openstate=0;
}
int pocz=0;
int kon=0;
while(pocz<kon){
int sr=(pocz+kon)/2;
change(pocz,sr,openstate);
change(sr+1,kon,!openstate);
ak=tryCombination(sent);
if(ak > j || ak==-1)
{
kon=sr;
}
else{
pocz=sr+1;
}
}
sent[pocz]=openstate;
match[j]=pocz;
fixed_[pocz]=1;
}
}