Grand Finale: Circles
Geometric feasibility problem (repository label: "Grand Finale: Circles"; exact external contest/source identity is not established in this repository text).
Input arg1 is a flat array encoding n circles as triples [x1, y1, r1, x2, y2, r2, ...] in order. Each triple (xi, yi, ri) is a circle with center (xi, yi) and radius ri.
Return the maximum radius r (a real number) of a circle that can be placed entirely inside the intersection of all given circles. Equivalently, there exists a point P with dist(P, (xi, yi)) <= ri - r for every circle.
Contract
- Output is a number. Absolute or relative tolerance of
1e-7class is appropriate for floating-point comparison when the platform applies numeric tolerance. - The intersection is feasible for the intended inputs; answers should reflect the true maximum feasible radius.
Examples
Input: [1,2,3]
Output: 3
Input: [2,3,4]
Output: 4
Hints
Find circle C contained in intersection of all given circles with maximum radius. Binary search radius r. Feasibility: does point (x,y) exist such that distance to each center ≤ ri − r?
Feasibility reduces to 1D: for a given r, x-range is intersection of [xi−(ri−r), xi+(ri−r)]. For each x, y-range is intersection of shifted half-circles. Check with ternary search on x.
Problem guaranteed feasible (radius ≥ 1e−6). Use absolute/relative tolerance 1e−7. n up to 1e5 so O(n log precision) is fine. Single ternary search on x suffices — the feasible region is convex.
Grand Finale: Circles
Geometric feasibility problem (repository label: "Grand Finale: Circles"; exact external contest/source identity is not established in this repository text).