제출 #648862

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

// int tryCombination(vector<int> &a);
// void answer(vector<int> &a, vector<int> &b);


void exploreCave(int n) {
    int pos[n], con[n];

    for (int i=0; i<n; i++) {
        // per a cada porta faig bs dels interruptors
        int l = i, r = n + 1;
        bool on = 1;
        while (r - l > 1) {
            int m = (l + r) / 2;
            bool can = 0;
            if (tryCombination(pos) == i) {
                on = 0;
                can = 1;
            }
            for (int j=i; j<m; j++) {
                pos[j] = 1;
            }
            if (tryCombination(pos) == i) {
                on = 1;
                can = 1;
            }

            if (can) {
                r = m;
            } else {
                l = r;
            }
        }
        pos[i] = on;
        con[i] = r;
    }

    answer(pos, con);
}
#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...