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 "grader.h"
int x;
int f(int a, int b, int c, int d, int xi, int yi){
if(a > c || b > d) return 0;
int r = (a + c) / 2;
int s = b, e = d;
if(xi == 0){
while(s <= e){
int m = (s + e) / 2;
int t = Measure(r, m);
if(t == x){ Pinpoint(r, m); return 1; }
else if(t > x) e = m - 1;
else s = m + 1;
}
}
else{
while(s <= e){
int m = (s + e) / 2;
int t = Measure(r, m);
if(t == x){ Pinpoint(r, m); return 1; }
else if(t < x) e = m - 1;
else s = m + 1;
}
}
int q = yi ^ xi;
return f(a, (q ? s : b), r - 1, (q ? d : s - 1), xi, yi) || f(r + 1, (q ? b : s), c, (q ? s - 1 : d), xi, yi);
}
void Rescue(int R, int C, int RS, int CS, int X) {
x = X;
if(f(1, 1, RS, CS, 0, 1)) return;
if(f(1, CS, RS, C, 1, 1)) return;
if(f(RS, 1, R, CS, 0, 0)) return;
f(RS, CS, R, C, 1, 0);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |