# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
144854 | youssefbou62 | 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;
#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
// int ab (int x ) { return (x>0?x:-x); }
int n ;
int cnt = 0 ;
int TryCombination(int S[]){
cnt++;
return tryCombination(S);
}
void exploreCave(int N){
n = N ;
int door[N],Combination[N]={0},Mode[N];
memset(door,-1,sizeof door);
int reply =0;
int C = 0 ;
for(int X = 0 ; X < n ; X++){
int l = 0 , r= N-1 ;
int last = TryCombination(Combination);
if( last == -1 )break ;
while ( l < r && reply != -1 ){
int mid = l + (r-l)/2;
if( l == r ){
door[r]=reply;
break ;
}
for(int i = l ; i < mid ; i++ ){
if( door[i] == -1 ){
Combination[i]= (!Combination[i]);
}
}
reply = TryCombination(Combination);
for(int i = l ; i < mid ; i++ ){
if( door[i] == -1 ){
Combination[i]= (!Combination[i]);
}
}
if( reply == last){
l = mid+1;
}else {
r = mid;
}
}
door[l]=reply ;
}
for(int i = 0 ; i < n ; i++ ){
if( door[i]==-1){
Combination[i]=!Combination[i];
reply = TryCombination(Combination);
door[i]=reply;
Combination[i]=!Combination[i];
}
}
answer(Combination,door);
}