#P8389. [COI 2021] Izvanzemaljci

[COI 2021] Izvanzemaljci

Problem Description

Translated from COI 2021 T3 "Izvanzemaljci".

There are NN integer points (xi,yi)(x_i, y_i) on a 2D plane. Find KK pairwise disjoint squares such that all integer points lie inside or on the boundary of the squares. If there are multiple solutions, choose the one that minimizes the area of the largest square among all valid constructions. If there are still multiple solutions, output any one of them.

Two squares are considered disjoint if their edges do not intersect or touch, and neither square is completely contained within the other.

Input Format

The first line contains two integers NN and KK.

The next NN lines each contain two integers xix_i and yiy_i.

Output Format

Output KK lines. Each line contains three integers aia_i, bib_i, and lil_i, indicating a square with lower-left corner (ai,bi)(a_i, b_i) and side length lil_i.

You must ensure that 0ai,bi3×1090 \le |a_i|, |b_i| \le 3 \times 10^9 and 1li2×1091 \le l_i \le 2 \times 10^9.

3 1
1 1
1 3
2 2
0 1 2
5 2
1 3
3 1
5 5
5 10
7 7
1 1 4
5 7 3
5 3
1 3
3 1
5 5
5 10
7 7

1 1 2
5 5 2
5 10 1

Hint

Sample Explanation

Explanation for Sample #2:

Explanation for Sample #3:

Constraints

For all testdata, 1N1051 \le N \le 10^5, 1K31 \le K \le 3, 0xi,yi1090 \le |x_i|, |y_i| \le 10^9.

Subtask Constraints Score
11 K=1K = 1 55
22 K=2K = 2 2121
33 N12N \le 12, K=3K = 3 1212
44 N103N \le 10^3, K=3K = 3 3030
55 K=3K = 3 3232

Translated by ChatGPT 5