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 ans[n];
int sw[n];
int idk[n];
for(int i = 0; i < n; i++) {
sw[i] = -1;
}
int l,r,m,x;
for(int i = 0; i < n; i++) {
l = 0;
r = n-1;
for(int j = 0; j < n; j++) {
idk[j] = max(0,sw[j]);
}
x = tryCombination(idk);
while(l < r) {
m = (l+r)/2;
for(int j = 0; j < n; j++) {
if(sw[j] != -1) {
idk[j] = sw[j];
}
else {
if(j >= l && j <= m) {
idk[j] = 1;
}
else {
idk[j] = 0;
}
}
}
if((tryCombination(idk) == i) != (x == i)) {
r = m;
}
else {
l = m+1;
}
}
ans[l] = i;
if(x == -1 || x > i) {
sw[l] = 0;
}
else {
sw[l] = 1;
}
}
answer(sw,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... |