Submission #223881

#TimeUsernameProblemLanguageResultExecution timeMemory
223881DS007Cave (IOI13_cave)C++14
0 / 100
75 ms504 KiB
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;

void exploreCave(int n) {
    int d_[n], s_[n];
    memset(d_, -1, sizeof(d_));

    for (int i = 0; i < n; i++) {
        int s[n];
        for (int j = 0; j < n; j++) {
            if (d_[i] == -1)
                s[i] = 0;
            else
                s[i] = s_[i];
        }

        int x = tryCombination(s);
        s_[i] = x == i;

        int l = 0, h = n - 1, ans = -1;

        while (l <= h) {
            int temp[n];
            memcpy(temp, s, n);
            int mid = (l + h) / 2;

            for (int j = l; j <= mid; j++)
                temp[j] = d_[i] == -1 ? 1 : s[i];

            int y = tryCombination(temp);
            if (x != y)
                ans = mid, h = mid - 1;
            else
                l = mid + 1;
        }

        d_[i] = ans;
    }

    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...