# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
168574 | nickmet2004 | Cave (IOI13_cave) | C++11 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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);
}