Submission #1039626

#TimeUsernameProblemLanguageResultExecution timeMemory
1039626AC2K산악 구조대 (JOI13_mountain)C++17
0 / 100
3 ms860 KiB
#include<bits/stdc++.h> #include "grader.h" using namespace std; void Rescue(int R, int C, int RS, int CS, int X) { int upper = max(RS - 1, R - RS) + max(CS - 1, C - CS), lower = 0; auto calc = [&](int d) { int res = 1e9; for (int i = 1; i <= R; ++i) { int dd = d - abs(i - RS); if (d < 0) continue; for (auto j : {CS - dd, CS + dd}) { if (j <= 0 || j > C) continue; int H = Measure(i, j); if (H == X) { Pinpoint(i, j); return -1; } res = min(res, H); } } return res; }; if (calc(upper) == -1) return; if (calc(lower) == -1) return; while (upper - lower > 1) { int mid = (upper + lower) / 2; int H = calc(mid); if (H == -1) return; (H >= X ? lower : upper) = mid; } if (calc(lower) == -1) return; if (calc(upper) == -1) return; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...