#P1382. 楼房

    ID: 377 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>线段树二叉堆福建省历届夏令营

楼房

Description

There are nn buildings on the horizon (the xx axis), and each building is represented as a rectangle.

The ii-th rectangle is represented by three integers hi,li,rih_i, l_i, r_i: its bottom-left corner is at (li,0)(l_i, 0) and its top-right corner is at (ri,hi)(r_i, h_i).

The horizon has height 00. Subject to minimizing the skyline polyline length (i.e., without redundant points), output the skyline from left to right.

Input Format

The first line contains an integer nn, the number of rectangles.

Each of the following nn lines contains 33 integers hi,li,rih_i, l_i, r_i describing the ii-th rectangle.

Output Format

The first line contains an integer mm, the number of nodes.

Each of the following mm lines contains one coordinate, representing a node on the skyline.

Traverse the skyline from left to right and output the nodes in order.

Note: The yy-coordinates of the first and the last node are both 00.

2
3 0 2
4 1 3

6
0 0
0 3
1 3
1 4
3 4
3 0
5
3 -3 0
2 -1 1
4 2 4
2 3 7
3 6 8
14
-3 0
-3 3
0 3
0 2
1 2
1 0
2 0
2 4
4 4
4 2
6 2
6 3
8 3
8 0

Hint

Sample 2 as shown:

Constraints:

For 30%30\% of the testdata, n100n \le 100.

For another 30%30\% of the testdata, 1hi,li,ri10001 \le h_i, l_i, r_i \le 1000.

For 100%100\% of the testdata, 1n1051 \le n \le 10^5, 1hi1091 \le h_i \le 10^9, 109li<ri109-10^9 \le l_i < r_i \le 10^9.

Translated by ChatGPT 5