제출 #1338017

#제출 시각아이디문제언어결과실행 시간메모리
1338017lex._.동굴 (IOI13_cave)C++20
100 / 100
263 ms492 KiB
#include "cave.h"
#define NMAX 5000
#define LOG 13

int s[NMAX], d[NMAX];
bool is_set[NMAX];

void set_bit(int st, int dr, int bit)
{
    for(int i=st; i<=dr; i++)
    {
        if(is_set[i]==0)
            s[i]=bit;
    }
}

void exploreCave(int N)
{
    for(int i=0; i<N; i++) d[i]=-1;
    for(int i=0; i<N; i++)
    {
        set_bit(0, N-1, 1);
        int door=tryCombination(s);

        bool bit_open;
        bit_open=(door!=i);

        set_bit(0, N-1, !bit_open);

        int pos=0;
        for(int e=LOG-1; e>=0; e--)
        {
            if(pos+(1<<e)<=N)
            {
                set_bit(pos, pos+(1<<e)-1, bit_open);
                int new_door=tryCombination(s);

                if(new_door==i) pos+=(1<<e);
                else set_bit(pos, pos+(1<<e)-1, !bit_open);
            }
        }
        d[pos]=i;
        is_set[pos]=1;
        s[pos]=bit_open;
    }
    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...