Ex - Disk and Segments Editorial by evima

Another solution by proposer

We perform a binary search on the answer. The answer is less than or equal to a certain value if and only if the following holds.

  • There are \(N\) shapes like the ones shown below, each formed by a rectangle and two semicircles. Is there a point where they all intersect? (The figures below correspond to Sample Input 1 and 2.)

Figure for Sample Input 1 Figure for Sample Input 2

By enumerating all intersections of \(2N\) line segments and \(2N\) circles, and calculating their distances from the \(N\) line segments, you can check this in \(O(N^3)\) time, barely in time.

Sample Implementation (C++)

P.S. I proposed A, B, D, E, and Ex.

posted:
last update: