問題一覧 > 通常問題

No.1069 Utility Pole / Pole (Hard)

レベル : / AI推定難易度 : 2000 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 小数誤差許容問題 絶対誤差または相対誤差が $10^{-4}$ 以下。ただし、ジャッジ側の都合で500桁未満にしてください
タグ : (AC するまで非表示) / 解いたユーザー数 22
作問者 : null / テスター : ngtkana
お気に入りにしたユーザー ProblemId : 4227 / 自分の提出
問題文最終更新日: 2026-10-22 01:11:26
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 250 (順位表) の他の問題:

About This Problem

The parts that differ from Easy are shown in bold or red. Note in particular that the input has changed.

Problem Statement

One day, as the null Tapunikia Kingdom began to flourish, a jolt of electricity ran through its king, null! However, the kingdom had no electricity!
Since this was far too inconvenient, he wanted to connect at least the power plant and the castle as soon as possible, so null entrusted you with estimating the wire consumption.

The wire consumption is defined as the sum of the lengths of the wire candidates used.
There are $N$ utility poles $1, 2, \dots, N$, and the coordinates of the $i(1 \le i \le N)$-th pole are $(p_i, q_i)$.
There are $M$ wire candidates, and the $j(1 \le j \le M)$-th wire candidate is the line segment connecting pole $P_j$ and pole $Q_j$.
Wires can be installed only on these candidates.
Pole $A$ and pole $B$ are said to be connected when one can reach pole $B$ from pole $A$ by following some installed wires.
It is guaranteed that when all wire candidates are used, all poles are used and connected.
It is also guaranteed that there is no wire candidate from a pole to itself, and that for any $2$ poles there is at most $1$ wire candidate connecting them.
Your task is to connect pole $X$, the power plant, and pole $Y$, the castle, and estimate $K$ values in ascending order of wire consumption. However, the same pole cannot be used twice in a single estimate.
Also, the wire candidates must be drawable in a single stroke. (Added at 21:46)

Input

$N\ M\ \color{red}{K}$
$X\ Y$
$p_1\ q_1$
$p_2\ q_2$
$\dots$
$p_N\ q_N$
$P_1\ Q_1$
$P_2\ Q_2$
$\dots$
$P_M\ Q_M$

$2 \le N \le \color{red}{2 \times 10^3}$
$\color{red}{1 \le K \le 10}$
$N - 1 \le M \le min(\frac{N(N - 1)}{2}, \color{red}{2 \times 10^3})$
$1 \le X, Y \le N$
$X \neq Y$
$10^3 \le p_i, q_i \le 10^3$
$1 \le P_j, Q_j \le N$
It is guaranteed that when all wire candidates are used, all poles are used and connected.
It is guaranteed that there is no wire candidate from a pole to itself, and that for any $2$ poles there is at most $1$ wire candidate connecting them.
All input values are integers.

Output

Output the wire usage for $K$ ways in ascending order of wire consumption when connecting pole $X$ and pole $Y$ using some pole candidates. If there are multiple routes with the same distance, each route counts as one.
An error is accepted if the smaller of the absolute error and the relative error is at most $10^{-4}$.
Print a newline at the end.

Sample

Sample 1
Input
5 4 1
2 4
0 0
-1 -1
1 -1
1 1
-1 1
1 2
1 3
1 4
1 5
Output
2.828427

The answer is $2 \sqrt{2}$.

Sample 2
Input
5 8 5
2 4
0 0
-1 -1
1 -1
1 1
-1 1
1 2
1 3
1 4
1 5
2 3
3 4
4 5
5 2
Output
2.828427
4.000000
4.000000
4.828427
4.828427

From top to bottom, these are $2 \sqrt{2}, 4, 4, 2 \sqrt{2} + 2, 2 \sqrt{2} + 2$.

Sample 3
Input
2 1 10
1 2
0 0
0 1
1 2
Output
1.000000
-1
-1
-1
-1
-1
-1
-1
-1
-1

Output -1 for every case that does not exist.

Sample 4
Input
2 1 2
1 2
0 0
0 0
1 2
Output
0.000000
-1

Note that a distance of $0$ is possible.

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