제출 #93837

#제출 시각아이디문제언어결과실행 시간메모리
93837alexpetrescu동굴 (IOI13_cave)C++14
63 / 100
2062 ms568 KiB
#include "cave.h"

#define MAXN 5000
#define LOGN 12

int s[MAXN], d[MAXN];
bool done[MAXN];

inline bool vezi(int a, bool k, int u, int n) {
    for (int i = 0; i <= a; i++)
        if (done[i] == 0)
            s[i] = k;
    for (int i = a + 1; i < n; i++)
        if (done[i] == 0)
            s[i] = 1 - k;
    bool ans = tryCombination(s) == u;
    for (int i = 0; i < n; i++)
        if (done[i] == 0)
            s[i] = 0;
    return ans;
}

void exploreCave(int n) {
    for (int i = 0; i < n; i++) {
        bool k = tryCombination(s) == i;
        int rez = -1;
        for (int pas = 1 << LOGN; pas; pas >>= 1)
            if (rez + pas < n - 1 && vezi(rez + pas, k, i, n))
                rez += pas;
        rez++;
        d[rez] = i;
        s[rez] = k;
        done[rez] = 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...