#P51453. [JOISC 2021 Day2] Road Construction
[JOISC 2021 Day2] Road Construction
Description
Original problem from JOISC 2021 Day2 T2 Road Construction.
There are N towns in JOI Kingdom. The towns are numbered from to . The land of JOI Kingdom is considered as the -plane. The coordinates of the town is .
In JOI Kingdom, they are planning to construct K roads connecting towns. It costs yen to construct a road connecting the town and the town . Note that we consider “the construction of a road connecting the town and the town ” and “the construction of a road connecting the town and the town ” to be the same.
Since you are in charge of the construction project, you want to know the cost to construct roads connecting some pairs of towns to construct roads, in order to estimate the cost. Among the pairs of towns to construct roads, you want to know the costs of the K cheapest roads.
Write a program which, given the coordinates of the towns of JOI Kingdom and the value of , calculates the costs of the cheapest roads.
Input Format
In the first line, there are two integers and .
In the following lines, there are two integers and each line.
Output Format
Output lines. In the -th line (, output the cost of the -th cheapest road.
Sample 1
3 2
-1 0
0 2
0 0
1
2
The coordinates of the town is , the coordinates of the town is , and the coordinates of the town is .
There are pairs of towns.
- It costs yen to construct a road connecting the town and the town .
- It costs yen to construct a road connecting the town and the town .
- It costs yen to construct a road connecting the town and the town .
The costs of the roads are from the cheapest. Therefore, output to the -st line, and output to the -nd line. This sample input satisfies the constraints of Subtasks .
5 4
1 -1
2 0
-1 0
0 2
0 -2
2
2
3
3
Since , there are pairs of towns.
The costs of the roads are from the cheapest. Therefore, the costs of the cheapest roads are .
This sample input satisfies the constraints of Subtasks .
4 6
0 0
1 0
3 0
4 0
1
1
2
3
3
4
This sample input satisfies the constraints of Subtasks .
10 10
10 -8
7 2
7 -8
-3 -6
-2 1
-8 6
8 -1
2 4
6 -6
2 -1
3
3
4
5
6
6
6
7
7
7
This sample input satisfies the constraints of Subtasks .
Constraints
For all test data, it is guaranteed that
Subtask# | Score | Additional Constraints |
---|---|---|
1 | 5 | |
2 | 6 | |
3 | 7 | |
4 | 20 | |
5 | 27 | |
6 | 35 | No special constraints |