Submission #759710

#TimeUsernameProblemLanguageResultExecution timeMemory
759710AndreyCave (IOI13_cave)C++14
100 / 100
736 ms480 KiB
#include "cave.h"
#include<bits/stdc++.h>
using namespace std;

void exploreCave(int n) {
    int ans[n];
    int sw[n];
    int idk[n];
    for(int i = 0; i < n; i++) {
        sw[i] = -1;
    }
    int l,r,m,x;
    for(int i = 0; i < n; i++) {
        l = 0;
        r = n-1;
        for(int j = 0; j < n; j++) {
            idk[j] = max(0,sw[j]);
        }
        x = tryCombination(idk);
        while(l < r) {
            m = (l+r)/2;
            for(int j = 0; j < n; j++) {
                if(sw[j] != -1) {
                    idk[j] = sw[j];
                }
                else {
                    if(j >= l && j <= m) {
                        idk[j] = 1;
                    }
                    else {
                        idk[j] = 0;
                    }
                }
            }
            if((tryCombination(idk) == i) != (x == i)) {
                r = m;
            }
            else {
                l = m+1;
            }
        }
        ans[l] = i;
        if(x == -1 || x > i) {
            sw[l] = 0;
        }
        else {
            sw[l] = 1;
        }
    }
    answer(sw,ans);
}
#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...