P17016 [GESP202606 Level 8] Wire Network Construction

Description

City A has $n$ base stations that need to be connected to each other through a wire network. The $i$-th base station is located at coordinates $(x_i, y_i)$ on a 2D plane. The distance between the $i$-th base station and the $j$-th base station is defined as $\sqrt{(x_i - x_j)^2 + (y_i - y_j)^2}$. If the distance between two base stations is no more than a given integer $l$, then a line connecting these two base stations can be built, and the line length is the distance between the two stations. If starting from one base station, you can reach another base station by traveling along a series of lines in the network, then these two base stations are considered connected to each other. What is the minimum total length of lines that must be built so that all $n$ base stations are mutually connected? If it is impossible to build a network that satisfies the condition, output `Impossible`.

Input Format

The first line contains two positive integers $n, l$, representing the number of base stations and the upper limit on the line length. The next $n$ lines each contain two integers $x_i, y_i$, representing the coordinates of a base station.

Output Format

Output one line. If a network satisfying the condition can be built, output the minimum total length of lines that need to be built, rounded to two decimal places. Otherwise output `Impossible`.

Explanation/Hint

### Constraints For $40\%$ of the testdata, it is guaranteed that $1 \le n \le 100$. For all testdata, it is guaranteed that $1 \le n \le 500$, $1 \le l \le 100$, $-100 \le x_i, y_i \le 100$. Translated by ChatGPT 5