Submission #331279

#TimeUsernameProblemLanguageResultExecution timeMemory
331279smaxCave (IOI13_cave)C++17
100 / 100
1164 ms656 KiB
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;

void exploreCave(int N) {
    vector<int> state(N), connect(N, N);
    for (int i=0; i<N; i++) {
        vector<int> guess(N);
        for (int j=0; j<N; j++) {
            if (connect[j] < i)
                guess[j] = state[j];
        }
        bool x = tryCombination(&guess[0]) == i;
        int l = 0, r = N;
        while (l < r) {
            int m = (l + r) / 2;
            for (int j=0; j<N; j++) {
                if (connect[j] < i)
                    guess[j] = state[j];
                else if (j < l || j >= r)
                    guess[j] = 0;
                else
                    guess[j] = j <= m;
            }
            bool y = tryCombination(&guess[0]) == i;
            if (x == y)
                l = m + 1;
            else
                r = m;
        }
        state[l] = x;
        connect[l] = i;
    }
    answer(&state[0], &connect[0]);
}
#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...