#abc309f. F - Box in Box

F - Box in Box

Score : 525525 points

问题描述

NN 个箱子。第 ii 个箱子的形状为长方体,其高度、宽度和深度分别为 hi,wih_i, w_idid_i

确定是否存在两个箱子,在必要时经过旋转后,其中一个箱子的高度、宽度和深度严格大于另一个箱子的对应尺寸。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

There are NN boxes. The ii-th box has a shape of a rectangular cuboid whose height, width, and depth are hi,wih_i,w_i, and did_i, respectively.

Determine if there are two boxes such that one's height, width, and depth are strictly greater than those of the other after rotating them if necessary.

Constraints

  • 2N2×1052 \leq N \leq 2 \times 10^5
  • 1hi,wi,di1091 \leq h_i,w_i,d_i \leq 10^9
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN

h1h_1 w1w_1 d1d_1

\vdots

hNh_N wNw_N dNd_N

Output

Print Yes if there are two boxes such that one's height, width, and depth are strictly greater than those of the other after rotating them if necessary; print No otherwise.

Sample Input 1

3
19 8 22
10 24 12
15 25 11

Sample Output 1

Yes

If you rotate the 22-nd box to swap its height and depth, the 33-rd box will have greater height, depth, and width.

Sample Input 2

3
19 8 22
10 25 12
15 24 11

Sample Output 2

No

Sample Input 3

2
1 1 2
1 2 2

Sample Output 3

No

update @ 2024/3/10 08:46:48