Important targets
Limits: 1 sec., 256 MiB
This statement was translated automatically from Ukrainian.
The Main Directorate of Intelligence learned about three large enemy equipment bases. Their coordinates are \((x_1, y_1)\), \((x_2, y_2)\), and \((x_3, y_3)\).
Zenyk was tasked with planning a special operation to destroy these targets.
To carry out the operation, the GUR can allocate to Zenyk at most three missiles with the same destruction radius. The destruction zone of a missile with a destruction radius \(R\) that hits the point \((x, y)\) is a circle of radius \(R\) centered at this point. A missile destroys all targets located inside its destruction zone. The destruction zone of the attack is defined as the union of the destruction zones of the missiles launched within this attack.
Zenyk needs to find out what minimum missile destruction radius he needs in order to achieve both goals of the special operation:
Destroy all three enemy bases.
Ensure the integrity of the attack’s destruction zone. That is, between every two hit points there must exist a path that passes within the destruction zone.
Input
The first three lines each contain two integers \(x_i\), \(y_i\) — the coordinates of the corresponding target.
Output
In a single line, output a single number — the minimum missile destruction radius that will satisfy both goals of the special operation.
The answer will be considered correct if the absolute or relative error does not exceed \(10^{-7}\).
Constraints
\(-1000 \le x_i, y_i \le 1000\),
if \(i \ne j\), then \((x_i, y_i) \ne (x_j, y_j)\) — no points coincide.
In at least five tests, the input points lie on the same line.
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 0 0 3 4 3 -2 | 1.25 |
| Input (stdin) | Output (stdout) |
|---|---|
| 0 0 0 1 0 6 | 1 |
Notes
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
Important targets - Editorial
First of all, one needed to notice that the radius \(R\) can be found with binary search, since increasing the radius of the circles only enlarges the hit area, which cannot lose connectivity. Now for a radius \(R\) we need to check whether three circles of this radius can be placed so that they cover the 3 given points and all circles are connected.
There are two cases: each circle contains a point, or one of the circles contains two points. The case when one circle contains 3 points need not be considered, since we could move this circle until one of the points is outside, then put that point into another circle and get the same situation as in the second case.
Consider the first case, where each point is in a separate circle. For the area covered by these circles to be connected, one circle must be connected to the other two.
The center of this circle must be at distance at most \(R\) from the point it covers, since otherwise it would not cover it. Also, the distance to the other two points must be at most \(3 \cdot R\), since otherwise we cannot place a circle that covers that point and has a common point with this circle. Now we need to tell whether such a center can exist. For this we check whether the circles of radii \(R\), \(3 \cdot R\) and \(3 \cdot R\) centered at the given points have a common point, since the set of points at distance at most \(d\) from a given point is the circle of radius \(d\) centered at it. Note that we need to consider which of the 3 given points must be at distance at most \(R\), while the other two must be at distance \(\le 3 \cdot R\).
The second case is similar, but here the center of the circle containing two points must be at distance at most \(R\) from these two points, and the distance to the third one must be at most \(5 \cdot R\), since we can place a circle containing no points as the connecting one.
So we need to check whether the circles of radii \(R\), \(R\) and \(5 \cdot R\) have a common point. As in the previous case, we need to consider which of the 3 points gets the circle of radius \(5 \cdot R\).
In both cases we need to tell whether three circles have at least one common point.
This subproblem can be solved as follows: take the intersection of two circles and check whether it belongs to the third circle; if so, the circles have a common point. Note that there may be no intersection, in which case we check nothing. We also need to consider the intersection of every pair of circles. This algorithm works if no circle lies inside another. However, there is only one variant where one circle is inside another and the 3 circles have a common point, but the algorithm above says the opposite.
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|