# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
71844 | yusufake | Cave (IOI13_cave) | C++98 | 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>
using namespace std;
#include "cave.h"
int A[5003],T[5003];
vector < int > v;
void exploreCave(int n) {
/* ... */
int i,j,l,m,r;
v.clear();
for(i=0;i<n;i++) v.pb(i);
for(i=0;i<n;i++){
l = 0;
r = v.size()-1;
if(tryCombination(T) == i){
for(; l<r ;){
m = l+r >> 1;
for(j=0;j<=m;j++) T[ v[j] ] = 1;
if(tryCombination(T) > i) r = m;
else l = m+1;
for(j=0;j<=m;j++) T[ v[j] ] = 0;
}
j = v[l];
A[j] = i;
T[j] = 1;
}
else{
for(; l<r ;){
m = l+r >> 1;
for(j=0;j<=m;j++) T[ v[j] ] = 1;
if(tryCombination(T) == i) r = m;
else l = m+1;
for(j=0;j<=m;j++) T[ v[j] ] = 0;
}
j = v[l];
A[j] = i;
T[j] = 0;
}
v.erase(v.begin() + l);
}
answer(T,A);
}