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 <vector>
using std::vector;
int A[5010], B[5010], n;
int ask(int S[]){
int res = tryCombination(S);
return res<0 ? 12345 : res;
}
int ask(int l, int r, int x){
static int S[5010];
for(int i=0; i<n; i++)
S[i] = (A[i]>=0 ? A[i] : (l<=i && i<=r ? x : 1-x));
return ask(S);
}
void exploreCave(int N) {
n = N;
for(int i=0; i<n; i++)
A[i] = B[i] = -1;
for(int i=0; i<n; i++){
// 다 끄고 물어봤을 때, i번째가 열렸으면 0;
int state = (i>=ask(-1, -1, 1));
int s=0, e=n-1;
while(s<e){
int mid = (s+e)/2;
if(i<ask(0, mid, state)) e = mid;
else s = mid+1;
}
B[s] = i, A[s] = state;
}
answer(A, B);
}
# | 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... |