# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1024436 | ZHIRDILBILDIZ | 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.
#include<bits/stdc++.h>
#include"cave.h"
using namespace std ;
void exploreCave(int N)
{
int S[N], [N] ;
vector<int> un_us, us;
for(int i = 0 ; i < N ; i++)
un_us.push_back(i), [i] = 0 ;
for(int i = 0 ; i < N ; i++)
{
for(int j : un_us)
S[j] = 0 ;
int trycomb = tryCombination(S);
if(trycomb == i)
{
int l = -1, r = un_us.size() ;
while(l + 1 < r)
{
int mid = (l + r) >> 1 ;
for(int j = 0 ; j <= mid ; j++)
S[un_us[j]] = 1 ;
if(tryCombination(S) == i)l = mid ;
else r = mid ;
for(int j = 0 ; j <= mid ; j++)
S[un_us[j]] = 0 ;
}
us.push_back(un_us[r]) ;
un_us.erase(r + un_us.begin()) ;
[us.back()] = i ;
S[us.back()] = 1 ;
}
else
{
int l = -1, r = un_us.size() ;
while(l + 1 < r)
{
int mid = (l + r) >> 1 ;
for(int j = 0 ; j <= mid ; j++)
S[un_us[j]] = 1 ;
if(tryCombination(S) == i)r = mid ;
else l = mid ;
for(int j = 0 ; j <= mid ; j++)
S[un_us[j]] = 0 ;
}
us.push_back(un_us[r]) ;
un_us.erase(r + un_us.begin()) ;
[us.back()] = i ;
S[us.back()] = 0 ;
}
}
answer(S, D) ;
}