# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
113702 | thebes | 동굴 (IOI13_cave) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MN = 5005;
int *arr, N, i, tmp, d[MN], s[MN];
void st(int l,int r,int v){
for(;l<=r;l++){
if(d[l]!=-1) arr[l]=d[l];
else arr[l]=v;
}
}
void rec(int l,int r,int id,int val){
if(l == r){
s[l] = id;
d[l] = val;
st(l,r,0);
return;
}
int m = l+r>>1;
st(l, m, !val);
int v = tryCombination(arr);
st(l, m, val);
if(v == id) rec(l, m, id, val);
else rec(m+1, r, id, val);
}
void exploreCave(int n){
N = n;
memset(d, -1, sizeof(d));
arr = (int*)malloc(N*sizeof(int));
for(i=0;i<N;i++){
int val = 0;
st(0,N-1,0);
if(tryCombination(arr)==i) val = 1;
else val = 0;
st(0,N-1,val);
rec(0,N-1,i,val);
}
answer(d, s);
}