Submission #24892

#TimeUsernameProblemLanguageResultExecution timeMemory
24892kdh9949산악 구조대 (JOI13_mountain)C++14
100 / 100
20 ms928 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...