Submission #813212

#TimeUsernameProblemLanguageResultExecution timeMemory
813212KerimCave (IOI13_cave)C++17
100 / 100
633 ms468 KiB
#include "cave.h"

void exploreCave(int n) {
    int a[n], b[n], c[n];
    for (int i = 0; i < n; i++)
        b[i] = -1, a[i] = 0;
    for (int i = 0; i < n; i++){
        int st = 0, en = n-1;
        int value = 0;
        if (tryCombination(a) == i)
            value = 1;
        while (st < en){
            int mid = (st + en) >> 1;
            for (int j = 0; j < n; j++){
                if (b[j] == -1)
                    c[j] = (j <= mid) ^ value;
                else    
                    c[j] = a[j];
            }
            if (tryCombination(c) == i)
                en = mid;
            else    
                st = mid + 1;
        }
        b[st] = i;
        a[st] = value;
    }
    answer(a, b);
}
#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...