游行AI (CI翻译)
No Great Victory anniversary in Berland has ever passed without the war parade. This year is not an exception. That’s why the preparations are on in full strength. Tanks are building a line, artillery mounts are ready to fire, soldiers are marching on the main square... And the air forces general Mr. Generalov is in trouble again. This year a lot of sky-scrapers have been built which makes it difficult for the airplanes to fly above the city. It was decided that the planes should fly strictly from south to north. Moreover, there must be no sky scraper on a plane’s route, otherwise the anniversary will become a tragedy. The Ministry of Building gave the data on $*n*$ sky scrapers (the rest of the buildings are rather small and will not be a problem to the planes). When looking at the city from south to north as a geometrical plane, the $*i*$-th building is a rectangle of height $*h*_{*i*}$. Its westernmost point has the x-coordinate of $*l*_{*i*}$ and the easternmost — of $*r*_{*i*}$. The terrain of the area is plain so that all the buildings stand on one level. Your task as the Ministry of Defence’s head programmer is to find an enveloping polyline using the data on the sky-scrapers. The polyline’s properties are as follows:
$*n*$ 座摩天大楼的数据(其余建筑都比较矮,不会对飞机造成影响)。从南向北观察城市,将其视为一个几何平面,第 $*i*$ 座建筑是高度为 $*h*_{*i*}$ 的矩形。它最西端的点的 x 坐标为 $*l*_{*i*}$,最东端的点的 x 坐标为 $*r*_{*i*}$。该区域地势平坦,因此所有建筑都矗立在同一水平面上。作为国防部的首席程序员,你的任务是根据摩天大楼的数据找出一条*包络*折线。折线需要满足以下性质:AI (CI翻译)- If you look at the city from south to north as a plane, then any part of any building will be inside or on the boarder of the area that the polyline encloses together with the land surface.
- The polyline starts and ends on the land level, i.e. at the height equal to 0.
- The segments of the polyline are parallel to the coordinate axes, i.e. they can only be vertical or horizontal.
- The polyline’s vertices should have integer coordinates.
- If you look at the city from south to north the polyline (together with the land surface) must enclose the minimum possible area.
- The polyline must have the smallest length among all the polylines, enclosing the minimum possible area with the land.
- The consecutive segments of the polyline must be perpendicular.
- 从南向北观察城市,将其视为一个平面,则任意建筑的任意部分都必须位于该折线与地面共同围成的区域内部或边界上。
- 折线的起点和终点都位于地面,即高度为 0。
- 折线的各条线段都平行于坐标轴,即只能是竖直线段或水平线段。
- 折线的顶点坐标必须为整数。
- 从南向北观察城市,折线与地面共同围成的区域面积必须尽可能小。
- 在所有与地面围成最小可能面积的折线中,折线长度必须最短。
- 折线中相邻的线段必须互相垂直。

AI (CI翻译)
Picture to the second sample test (the enveloping polyline is marked on the right).
第二个样例测试的示意图(右侧标出了包络折线)。AI (CI翻译)
Input
输入格式
AI (CI翻译)The first input line contains integer $*n*$ ($1 ≤ *n* ≤ 100000$). Then follow $*n*$ lines, each containing three integers $*h*_{*i*}$, $*l*_{*i*}$, $*r*_{*i*}$ ($1 ≤ *h*_{*i*} ≤ 10^{9}, - 10^{9} ≤ *l*_{*i*} < *r*_{*i*} ≤ 10^{9}$).
第一行包含一个整数 $*n*$($1 ≤ *n* ≤ 100000$)。接下来 $*n*$ 行,每行包含三个整数 $*h*_{*i*}$、$*l*_{*i*}$ 和 $*r*_{*i*}$($1 ≤ *h*_{*i*} ≤ 10^{9}, - 10^{9} ≤ *l*_{*i*} < *r*_{*i*} ≤ 10^{9}$)。AI (CI翻译)
Output
输出格式
AI (CI翻译)In the first line output integer $*m*$ — amount of vertices of the enveloping polyline. The next $*m*$ lines should contain 2 integers each — the position and the height of the polyline’s vertex. Output the coordinates of each vertex in the order of traversing the polyline from west to east. Remember that the first and the last vertices of the polyline should have the height of 0.
第一行输出一个整数 $*m*$,表示包络折线的顶点数。接下来的 $*m*$ 行每行包含两个整数,分别表示折线顶点的位置和高度。按照从西向东遍历折线的顺序输出每个顶点的坐标。注意,折线的第一个和最后一个顶点的高度必须为 0。
AI (CI翻译)
样例
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
题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。