# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
668434 | allin27x | 동굴 (IOI13_cave) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;
int tryCombination(int S[]);
void answer(int S[], int D[]);
void exploreCave(int N){
int doors[N]={};
int perm[N] = {};
unordered_set<int> f;
int tr[N] = {};
for (int s=0; s<N; s++){
int a = 0, b = N-1;
int pos = 0;
for (int i=0; i<N; i++){
if (f.count(i)) tr[i] = perm[i]; else tr[i]=0;
}
int r = tryCombination(tr);
if (r==s) pos = 1;
while (a!=b){
int m = (a+b)/2;
for (int i=0; i<N; i++){
if (f.count(i)) tr[i] = perm[i]; else tr[i]=(i<=m)?pos:!pos;
}
r = tryCombination(tr);
if (r==s) a = m+1; else b =m;
}
doors[a] = s;
perm[a] = pos;
f.insert(a);
}
answer(perm, doors);
}