No.96 Out of Range.
タグ : / 解いたユーザー数 69
作問者 :
Problem Statement
Taro and Jiro are talking to each other using radios.
The radios they use communicate directly with each other by radio waves,
and they can talk at distances of up to \(1km\).
In addition, the communication distance can be extended by placing \(1\) or more relay stations between them.
Communication between a radio and a relay station is possible only within \(1km\),
while communication between two relay stations is possible within \(10km\).
(These include exactly \(1km\) and exactly \(10km\), respectively.)
\(N\) relay stations stand on a 2-dimensional plane,
and their positions are represented by \(X_i,Y_i\ (1 \leq i \leq N)\).
Taro and Jiro can freely use all of these relay stations,
and they can move freely on the 2-dimensional plane carrying their radios. Under these conditions,
find the maximum straight-line (Euclidean) distance between Taro and Jiro
at which they can talk, either "directly" or "indirectly through relay stations".
Input
\(N\) \(X_1\ Y_1\) \(X_2\ Y_2\) \(\dots\) \(X_i\ Y_i\) \(\dots\) \(X_N\ Y_N\)
Line \(1\) contains an integer \(N\ (0 \leq N \leq 120000)\), the number of relay stations.
Each of the following \(N\) lines contains a pair of integers \(X_i,Y_i\ (-10000 \leq X_i,Y_i \leq 10000, 1 \leq i \leq N)\) separated by a space, representing the position of each relay station. (Unit: \([km]\))
No two relay stations exist at the same coordinates.
That is,
if $i \neq j $, then $(X_i,Y_i) \neq (X_j,Y_j)$.
Output
Output the maximum straight-line distance at which Taro and Jiro can talk.
The answer is accepted if at least one of the absolute error or the relative error is at most \(10^{−6}\).
Print a newline at the end.
Sample
Sample 1
Input
2 3 3 12 1
Output
11.219544457
The distance between the \(2\) relay stations is \(\sqrt{85}km\), which is within communication range.
Furthermore, Taro can communicate with a relay station at up to \(1km\), and Jiro can also communicate with a relay station at up to \(1km\),
so by standing on the extension of the straight line connecting the \(2\) relay stations,
they can communicate at up to \((\sqrt{85}+2)km\).
Sample 2
Input
2 -5 -1 3 6
Output
2
The distance between the \(2\) relay stations is about \(10.6km\), so they cannot communicate with each other.
In this case, using either \(1\) of the relay stations between them, Taro can communicate with the relay station at up to \(1km\),
and Jiro can also communicate with the relay station at up to \(1km\), so the answer is \(2km\).
Sample 3
Input
5 -8 7 -5 -1 3 5 9 -3 16 4
Output
26.186773244
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。