Submission #832970

#TimeUsernameProblemLanguageResultExecution timeMemory
832970HaroldVemenoCave (IOI13_cave)C++17
100 / 100
177 ms532 KiB
#include "cave.h"
#include <bits/stdc++.h>

#ifdef GUDEB
    #define D(x) cerr << #x << ": " << (x) << '\n';
    #define ifdeb if(true)
#else
    #define D(x) ;
    #define ifdeb if(false)
#endif

#define all(x) begin(x), end(x)

using namespace std;
using ull = unsigned long long;
using ll = long long;
// #define int ll;

int ind[5000];
int w[5000];

void exploreCave(int N) {
    fill(ind, ind + N, -1);

    for(int i = 0; i < N; ++i) {
        int b = 0;
        int e = N;
        int as = tryCombination(w);
        D(i)
        while(e-b > 1) {
            D(b)
            D(e)
            int m = (b+e)/2;
            for(int j = b; j < m; ++j) {
                if(ind[j] == -1) w[j] = 1-w[j];
            }
            D(as)
            int bs = tryCombination(w);
            if((as == i) == (bs == i)) {
                b = m;
            } else {
                e = m;
            }
            as = bs;
        }
        if(as == i) {
            w[b] = 1-w[b];
        }
        ind[b] = i;
    }
    answer(w, ind);

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