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<bits/stdc++.h>
#include "cave.h"
using namespace std;
int a[5010], cc[5010], sw[5010];
void exploreCave(int n) {
memset(cc, -1, sizeof cc);
memset(sw, -1, sizeof sw);
for(int i = 0; i < n; i++){
if (cc[i]!=-1 && sw[i]!=-1) continue;
for(int j = 0; j < n; j++){
if (j < i) a[j] = cc[j];
else a[j] = 0;
}
int result = tryCombination(a);
if (result == -1) {
for(int i = 0; i < n; i++) sw[i] = a[i];
}
bool io = (result > i);
if (io) sw[i] = 0;
else sw[i] = 1;
if (cc[i]!=-1 && sw[i]!=-1) continue;
int l = i, r = n-1;
while(l < r) {
int mid = (l+r)>>1;
for(int j = 0; j < i; j++) a[j] = cc[j];
for(int j = i; j <= mid; j++) a[j] = 1;
int res = tryCombination(a);
if (res == -1) {
for(int i = 0; i < n; i++) sw[i] = a[i];
}
if ((res>i)^io) r = mid;
else l = mid + 1;
}
if (cc[i]!=-1 && sw[i]!=-1) continue;
cc[i] = l;
}
answer(sw, cc);
}
# | 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... |