# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
168573 | nickmet2004 | Cave (IOI13_cave) | C++11 | 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 N;
vector<int> explored;
vector<int> Switch , D;
void change(int x , int y){
while(x <= y){
if(!explored[x]){
Switch[x] = (Switch[x] + 1) % 2;
}
++x;
}
}
void open(int idx){
int l = 0; int r = n - 1;
int ret , s1 , s2;
ret = tryCombination(Switch);
s1 = (ret > idx) || (ret == -1) ? 0 : 1;
while(l <= r){
int mid = (l + r) >> 1;
change(l , mid);
ret = tryCombination(Switch);
s2 = (ret > idx) || (ret == -1) ? 0 : 1;
if(s1 != s2){
r = mid - 1;
} else {
l = mid;
}
}
Switch[l] = s1;
D[l] = idx;
explored[idx] = 1;
}
void exploreCave(int N){
N = n;
for(int i = 0; i < N; ++i){
open(i);
}
answer(Switch , D);
}