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;
typedef long long ll;
const int MAX = 2e6 + 15;
const int INF = 0x3f3f3f3f;
int n, S[MAX], D[MAX];
bool mark[MAX];
bool f(int l, int r, int m, int j, int c){
for(int i = l; i < m; i++) if(!mark[i]) S[i] = c;
for(int i = m; i <= r; i++) if(!mark[i]) S[i] = !c;
int query = tryCombination(S);
return (query != j);
}
void exploreCave(int n_){
n = n_;
for(int door = 0; door < n; door++){
for(int i = 0; i < n; i++)
if(!mark[i]) S[i] = 0;
int color = (tryCombination(S) == door);
int l = 0, r = n - 1, pos = -1;
while(l <= r){
int m = (l + r) >> 1;
if(f(l, r, m, door, color)) r = m - 1, pos = m;
else l = m + 1;
}
mark[pos] = true;
D[pos] = door;
S[pos] = color;
}
answer(S, D);
}
# | 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... |