| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1310661 | nikoloz-ch | 동굴 (IOI13_cave) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;
vector<int> s;
void exploreCave(int N){
s.resize(N);
for(int i = 0; i < N; i++) s[i] = -1;
for(int i = 0; i < N; i++){
auto p = s; bool tr = true;
for(int j = 0; j < N; j++)
if(s[j] == -1) s[j] = 1;
int t = tryCombination(p);
if(t >= i+1) tr = !tr;
int l = 0, r = 0, ans = 0;
while(l < r){
int m = (l+r)/2; auto pt = s;
for(int j = 0; j < m; j++)
if(pt[j] == -1) pt[j] = (tr ? 1 : 0);
int d = tryCombination(pt);
if(d >= i+1) l = m;
else r = m;
if(l == r-1){
ans = m;
break;
}
}
s[ans] = (tr ? 1 : 0);
}
}
