#P1105. 平台

平台

Description

There are several platforms in space. Given the position of each platform, determine which platform you will land on after stepping off each platform’s edges.

Note: If the x-coordinates of some edge of two platforms are the same, then an object falling from the upper platform will not land on the lower one (i.e., each platform covers an open interval, excluding endpoints). Platforms may overlap.

When stepping off a platform, the fall is considered to start just below that platform, so you will not land on a platform of the same height. If there are two platforms with the same height that are both eligible to be landed on, you will land on the one with the smaller index.

Input Format

The first line contains an integer NN, the number of platforms.

Each of the next NN lines contains three integers: the height HiH_i, the left endpoint’s XX-coordinate LiL_i, and the right endpoint’s XX-coordinate RiR_i.

Constraints: 1N1031 \le N \le 10^3, 0H,L,R2×1040 \le H, L, R \le 2 \times 10^4.

Output Format

Output NN lines. For each ii, output two integers: the index of the platform reached by falling from the left edge of platform ii, and the index reached by falling from the right edge of platform ii.

Platforms are numbered from 11 in the input. If there is no platform below a given edge, output 00.

5
2 0 2
4 1 3
3 1 3
5 3 4
1 1 5

0 5
1 5
1 5
5 5
0 0

Hint

Translated by ChatGPT 5