loj#P3491. 「JOISC 2021 Day2」道路建设
「JOISC 2021 Day2」道路建设
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.
3 2
-1 0
0 2
0 0
1
2
5 4
1 -1
2 0
-1 0
0 2
0 -2
2
2
3
3
4 6
0 0
1 0
3 0
4 0
1
1
2
3
3
4
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
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 |