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 11 to NN. The land of JOI Kingdom is considered as the xyxy-plane. The coordinates of the town ii (1iN)(1 \leq i \leq N) is (Xi,Yi)(X_i, Y_i).

In JOI Kingdom, they are planning to construct K roads connecting towns. It costs XiXj+YiYj|X_i − X_j| + |Y_i − Y_j| yen to construct a road connecting the town ii and the town j (ij)j~(i \neq j). Note that we consider “the construction of a road connecting the town ii and the town jj” and “the construction of a road connecting the town jj and the town ii” 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 N(N1)2\frac{N(N − 1)}{ 2 } 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 KK, calculates the costs of the KK cheapest roads.

Input Format

In the first line, there are two integers NN and KK.

In the following NN lines, there are two integers XiX_i and YiY_i each line.

Output Format

Output kk lines. In the kk-th line (1kK)1 \leq k \leq K), output the cost of the kk-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 2N250000, 2\le N\le 250000,~1Kmin(250000,N(N1)2), 1\le K\le\min(250000, \frac{N(N-1)}{2}),~109Xi, Yi109, -10^9\le X_i,~Y_i\le 10^9,~(Xi, Yi)(Xj,Yj)(1i<jN)(X_i,~Y_i)\neq (X_j,Y_j) (1\le i < j\le N)

Subtask# Score Additional Constraints
1 5 N103N\le 10^3
2 6 Yi=0Y_i=0
3 7 K=1K=1
4 20 K10K\le 10
5 27 N105N\le 10^5
6 35 No special constraints