| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 58067 | naderjemel | 동굴 (IOI13_cave) | C++14 | 0 ms | 0 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int s[5000],ss[5000],d[5000];
void exploreCave(int N) {
    for(int i=0;i<N;i++){
    	s[i]=0;
    	d[i]=-1;
    }
    bool done[5005];
    memset(done,false,sizeof(done));
    for(int i=0;i<N;i++){
    	int lo=0,hi=N-1;
    	int rs;
    	int r=tryCombination(s);
    	if(r==i){ // it opens with 1
    		while(lo<=hi){
    			int mid=(lo+hi)>>1;
    			for(int j=mid;j<N;j++) ss[j]=s[j];
    			for(int j=lo;j<=mid;j++){
    				if(done[j]) ss[j]=s[j];
    				else ss[j]=1;
    			}
    			int rr=tryCombination(ss);
    			if(rr==i){
    				lo=mid+1;
    			}
    			else{
    				hi=mid-1;
    				rs=mid;
    			}
    		}
    		d[rs]=i;
    		done[rs]=true;
    		s[rs]=1;
    	}
    	else{ // it opens with 0
    		while(lo<=hi){
    			int mid=(lo+hi)>>1;
    			for(int j=mid;j<N;j++) ss[j]=s[j];
    			for(int j=lo;j<=mid;j++){
    				if(done[j]) ss[j]=s[j];
    				else ss[j]=1;
    			}
    			int rr=tryCombination(ss);
    			if(rr==i){
    				hi=mid-1;
    				rs=mid;
    			}
    			else{
    				lo=mid+1;
    			}
    		}
    		d[rs]=i;
    		done[rs]=true;
    		s[rs]=0;
    	}
    }
    answer(s,d);
}
