Submission #759684

#TimeUsernameProblemLanguageResultExecution timeMemory
759684Andrey동굴 (IOI13_cave)C++14
0 / 100
275 ms392 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;
        x = tryCombination(sw);
        while(l < r) {
            m = (l+r)/2;
            for(int j = 0; j < n; j++) {
                if(idk[j] != -1) {
                    idk[j] = sw[j];
                }
                else {
                    if(j >= l && j <= m && sw[i] != -1) {
                        idk[j] = 1;
                    }
                    else {
                        idk[j] = 0;
                    }
                }
            }
            if(tryCombination(sw) == x) {
                r = m;
            }
            else {
                l = m+1;
            }
        }
        ans[i] = l;
        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...