Submission #1076452

# Submission time Handle Problem Language Result Execution time Memory
1076452 2024-08-26T14:02:11 Z juicy Cave (IOI13_cave) C++17
0 / 100
89 ms 860 KB
#include "cave.h"

#include <bits/stdc++.h>

int S[5000], D[5000], q[5000];

void exploreCave(int N) {
    memset(S, -1, sizeof(S));
    auto search = [&]() {
        std::vector<int> cands;
        for (int i = 0; i < N; ++i) {
            if (S[i] != -1) {
                q[D[i]] = S[i];
            } else {
                cands.push_back(D[i]);
                q[D[i]] = 0;
            }
        }
        int door = tryCombination(q);
        if (door == -1) {
            q[cands[0]] = 1;
            door = tryCombination(q);
            D[cands[0]] = door;
            S[cands[0]] = 0;
            return;
        }
        int l = 0, r = cands.size() - 1, p = -1;
        while (l <= r) {
            int md = (l + r) / 2;
            for (int i = 0; i <= md; ++i) {
                q[cands[i]] = 1;
            }
            if (tryCombination(q) == door) {
                p = md;
                r = md - 1;
            } else {
                l = md + 1;
            }
            for (int i = 0; i <= md; ++i) {
                q[cands[i]] = 0;
            }
        }
        assert(~p);
        D[cands[p]] = door;
        S[cands[p]] = 1;
    };
    int cnt = 0;
    while (cnt++ < N) {
        search();
    }
    answer(S, D);
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 860 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 89 ms 604 KB Answer is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Answer is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Answer is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 860 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -