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;
void exploreCave(int N) {
int n = N;
bool fixed[n];
int con[n];
for (int i = 0; i < n; i++) fixed[i] = false;
int ans[n];
int v;
for (int i = 0; i < n; i++){
//try all 0s
for (int j = 0; j < n; j++){
if (!fixed[j]) con[j] = 0;
}
v = tryCombination(con);
int got = 1;
if (v >= i + 1) got = 0;
int l = 0, r = n - 1;
while (r != l){
int m = (l + r)/2;
//check if answer is among [l, mid]
for (int j = 0; j < n; j++) {
if (fixed[j]) continue;
if (j >= l && j <= m) con[j] = got;
else con[j] = got ^ 1;
}
v = tryCombination(con);
if (v >= i + 1) r = m;
else l = m + 1;
}
con[l] = got;
fixed[l] = true;
ans[l] = i;
}
answer(con, ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |