QOJ.ac

QOJ

Limite de temps : 3.0 s Limite de mémoire : 1024 MB Points totaux : 100

#8179. 二维括号

Statistiques

在二维平面上,有 $N$ 个左括号和 $N$ 个右括号。第 $i$ 个左括号的坐标为 $(x_{1,i}, y_{1,i})$,第 $i$ 个右括号的坐标为 $(x_{2,i}, y_{2,i})$。

你需要执行 $N$ 次以下操作来在平面上排列矩形:

  • 在平面上选择一个左括号和一个右括号。如果所选左括号的坐标为 $(x_1, y_1)$,所选右括号的坐标为 $(x_2, y_2)$,则必须满足 $x_1 < x_2$ 且 $y_1 < y_2$。
  • 从平面上移除所选的左括号和右括号,并在平面上放置一个顶点位于 $(x_1, y_1), (x_1, y_2), (x_2, y_2), (x_2, y_1)$ 的矩形。

确定是否可以以满足以下条件的方式排列 $N$ 个矩形。如果可以,请提供一种这样的排列方式。

  • 对于任意两个不同的矩形,它们的公共面积要么为 0,要么其中一个完全包含在另一个内部。

输入格式

输入通过标准输入按以下格式给出:

$N$ $x_{1,1} \ y_{1,1}$ $x_{1,2} \ y_{1,2}$ $\vdots$ $x_{1,N} \ y_{1,N}$ $x_{2,1} \ y_{2,1}$ $x_{2,2} \ y_{2,2}$ $\vdots$ $x_{2,N} \ y_{2,N}$

  • 输入中的所有值均为整数。
  • $1 \le N \le 2 \times 10^5$
  • $-10^9 \le x_{p,i}, y_{p,i} \le 10^9$
  • 如果 $(p, i) \neq (q, j)$,则 $(x_{p,i}, y_{p,i}) \neq (x_{q,j}, y_{q,j})$。

输出格式

如果不存在满足条件的排列,请在单行内输出 No。 如果存在满足条件的排列,请首先在单行内输出 Yes。之后,对于每个 $i = 1, 2, \dots, N$,输出与第 $i$ 个左括号对应的右括号的索引 $c_i$。 如果存在多种满足条件的排列,输出其中任意一种即可。

样例

样例 1

3
0 0
2 -2
1 1
2 2
3 1
2 3
Yes
3
2
1

样例 2

2
1 0
0 1
2 3
3 2
No

样例 3

1
1 1
0 0
No

说明

在第一个样例中,按照图中所示排列矩形满足条件。 在图中,圆圈代表左括号,叉号代表右括号。

在第二个样例中,如图所示,无论矩形如何排列,都无法满足条件。

在第三个样例中,很遗憾,无法排列出矩形。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.