# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
648860 | JANCARAPAN | Cave (IOI13_cave) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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) {
vector<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);
}