Submission #1202089

#TimeUsernameProblemLanguageResultExecution timeMemory
1202089totoroCave (IOI13_cave)C++20
0 / 100
37 ms324 KiB
#include "cave.h"

#include <vector>

void exploreCave(int N) {
    std::vector<int> matchesto(N);
    std::vector<int> fixed(N);
    for (int i = 0; i < N; ++i) {
        int lo = 0, hi = N - 1;
        std::vector<int> S(N);
        for (int j = 0; j < N; ++j) {
            if (fixed[j])
                S[j] = fixed[j] - 1;
            else
                S[j] = 1;
        }
        int last = tryCombination(S.data());
        while (lo < hi) {
            int mid = (lo + hi) / 2;
            for (int j = lo; j <= mid; ++j) {
                if (matchesto[j])
                    S[j] = fixed[j];
                else
                    S[j] ^= 1;
            }
            int now = tryCombination(S.data());
            if (now == last)
                lo = mid + 1;
            else
                hi = mid;
        }
        matchesto[lo] = i;
        fixed[lo] = S[lo] + 1;
    }

    answer(fixed.data(), matchesto.data());
}
#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...