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 fixed[N], ans[N];
for(int i = 0; i < N; i ++)fixed[i] = -1;
for(int i = 0; i < N; i ++){
int l = 0, r = N - 1;
int cur_x[N], res = 0;
bool open;
for(int j = 0; j < N; j ++)if(fixed[j] == -1)cur_x[j] = 1; else cur_x[j] = fixed[j];
int p = tryCombination(cur_x);
if(p > i || p == -1) open = 1;
else open = 0;
while(l < r){
int m = (l + r) >> 1;
for(int j = l; j <= m; j ++) if(fixed[j] == -1) cur_x[j] = open; else cur_x[j] = fixed[j];
for(int j = 0; j < N; j ++) if(j < l || j > r){if(fixed[j] == -1) cur_x[j] = open ^ 1; else cur_x[j] = fixed[j];}
int p = tryCombination(cur_x);
if(p > i || p == -1){
r = m;
}else{
l = m + 1;
}
}
res = l;
ans[res] = i;
fixed[res] = open;
}
answer(fixed, 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... |