# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
301339 | peti1234 | 동굴 (IOI13_cave) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;
const int c=5002;
int par[c];
bool v[c], t[c];
int f(int a, int b) {
for (int i=a; i<b; i++) if (!v[i]) t[i]=1-t[i];
}
bool jo(int p) {
int x=tryCombination(t);
if (x==-1) x=1e9;
return x>p;
}
void exploreCave(int n) {
for (int i=0; i<n; i++) {
if (!jo(i)) f(0, n);
int lo=0, hi=n;
while(hi-lo>1) {
int mid=(hi+lo)/2;
f(mid, hi);
if (jo(i)) hi=mid;
else lo=mid, f(mid, hi);
}
par[lo]=i, v[lo]=1;
}
answer(t, par);
}