제출 #16185

#제출 시각아이디문제언어결과실행 시간메모리
16185ggoh동굴 (IOI13_cave)C++98
100 / 100
555 ms640 KiB
#include<cstdio>
#include "cave.h"


void exploreCave(int N)
{
	int D[5555]={},S[5555]={},s[5555]={};
	bool C[5555]={};
    int i,p,q,h,ch,ima;
    for(i=0;i<N;i++)
    {
        p=0;q=N;ch=0;
        for(int j=0;j<N;j++)
        {
            if(C[j])s[j]=S[j];
            else s[j]=0;
        }
        ima=tryCombination(s);
        if(ima!=i)
        {
            for(int j=0;j<N;j++)
            {
                if(C[j])s[j]=S[j];
                else s[j]=1;
            }
            ch=1;
        }
        while(p!=q-1)
        {
            h=(p+q)/2;
            for(int j=p;j<h;j++)
            {
                if(C[j])s[j]=S[j];
                else s[j]=1-ch;
            }
            ima=tryCombination(s);
            for(int j=p;j<h;j++)
            {
                if(C[j])s[j]=S[j];
                else s[j]=ch;
            }
            if(ima==-1)ima=N;
            if(ima==i)p=h;
            else q=h;

        }
        S[p]=1-ch;
        D[p]=i;
        C[p]=1;
    }
    answer(S,D);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...