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<algorithm>
using namespace std;
static int p[5005], v[5005], s[5005];
void exploreCave(int n) {
int i, st, dr, mid, j, c;
for(i = 0; i < n; i++){
p[i] = -1;
}
for(i = 0; i < n; i++){
for(j = 0; j < n; j++){
if(p[j] != -1){
v[j] = s[j];
}
else{
v[j] = 0;
}
}
if( tryCombination(v) != i ){
c = 0;
}
else{
c = 1;
}
st = 0;
dr = n - 1;
while(st <= dr){
mid = (st + dr) / 2;
for(j = 0; j < n; j++){
if(p[j] != -1){
v[j] = s[j];
}
else{
if(j <= mid){
v[j] = c;
}
else{
v[j] = 1 - c;
}
}
}
if(tryCombination(v) != i){
dr = mid - 1;
}
else{
st = mid + 1;
}
}
p[st] = i;
s[st] = c;
}
answer(s, p);
}
# | 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... |