Submission #542958

#TimeUsernameProblemLanguageResultExecution timeMemory
542958pokmui9909Cave (IOI13_cave)C++17
0 / 100
15 ms340 KiB
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int sw[5005], match[5005];

void exploreCave(int N) {
    memset(match, -1, sizeof(match));
    for(int i = 0; i < N; i++){
        ll L = 0, R = N - 1;
        bool f = (tryCombination(sw) == i);
        while(L <= R){
            ll m = (L + R) / 2;
            for(int j = L; j <= m; j++){
                if(match[j] == -1){
                    sw[j] = 1;
                }
            }
            if(tryCombination(sw) == f) L = m + 1;
            else R = m - 1;
            for(int j = L; j <= m; j++){
                if(match[j] == -1){
                    sw[j] = 0;
                }
            }
        }
        match[L] = i, sw[L] = f;
    }
    answer(sw, match);
}
#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...