제출 #481189

#제출 시각아이디문제언어결과실행 시간메모리
481189nadorb동굴 (IOI13_cave)C++14
0 / 100
442 ms380 KiB
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;

void exploreCave(int n) {
    int s[n], known[n], whereto[n];
    for(int i = 0; i < n; i++){
        known[i] = -1;
        whereto[i] = -1;
    }
    for(int i = 0; i < n; i++){ // minden ajtora
        for(int j = 0; j < n; j++){
            if(known[j] == -1){
                s[j] = 1;
            }
            else{
                s[j] = known[j];
            }
        }
        int g = tryCombination(s);
        bool  door = (g == -1 || g > i);
        int l = 0, r = n - 1;
        while(l < r && i < n - 1){
            int mid = (l + r) / 2;
            for(int j = 0; j < n; j++){
                if(known[j] > -1){
                    s[j] = known[j];
                }
                else{
                    if(l <= j && j <= mid){
                        s[j] = door;
                    }
                    else{
                        s[j] = 1 - door;
                    }
                }
            }
            int res = tryCombination(s);
            if(res == - 1 || res > i){
                r = mid;
            }
            else{
                l = mid + 1;
            }
        }
        if(i == n - 1){
            for(int j = 0; j < n; j++){
                if(whereto[j] == -1){
                    whereto[j] = n - 1;
                    known[j] = door;
                }
            }
        }
        whereto[l] = i;
        known[l] = door;
    }
    answer(known, whereto);
}
#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...