問題一覧 > 通常問題

No.94 Out of Range. (EASY)

レベル : / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 小数誤差許容問題 絶対誤差または相対誤差が $10^{-6}$ 以下。ただし、ジャッジ側の都合で500桁未満にしてください
タグ : (AC するまで非表示) / 解いたユーザー数 191
作問者 : なお
お気に入りにしたユーザー ProblemId : 103 / 自分の提出
問題文最終更新日: 2026-06-25 03:44:00
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 57 (順位表) の他の問題:

Problem Statement

Taro and Jiro are talking to each other using radios.

The radios the two are using communicate directly with each other by radio waves,
and allow them to talk at distances of up to \(1km\).
Apart from this, the communication distance can also be extended by placing \(1\) or more relay stations in between.

A radio and a relay station can communicate only within \(1km\),
whereas two relay stations can communicate within \(10km\).
(These include exactly \(1km\) and exactly \(10km\), respectively.)

There are \(N\) relay stations standing on a 2-dimensional plane,
and their positions are given 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 distance (Euclidean distance) between Taro and Jiro at which they can talk
either "directly" or "indirectly using 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 1000)\), the number of relay stations.
Each of the following \(N\) lines contains a pair of integers \(X_i,Y_i\ (-1000 \leq X_i,Y_i \leq 1000, 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.
Your 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\), so they are within communication range.
In addition, Taro and a relay station can communicate up to \(1km\), and Jiro and a relay station can also communicate up to \(1km\),
so by having the two stand on the extension of the straight line connecting the \(2\) relay stations,
communication is possible 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.
In this case, using either \(1\) of the relay stations in between, Taro and the relay station can communicate up to \(1km\),
and Jiro and the relay station can also communicate 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

Sample 4
Input
0
Output
1

When there are no relay stations, they must communicate directly.
In this case, the maximum distance is \(1km\), the range within which their radio waves reach each other.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。