QOJ.ac

QOJ

Límite de tiempo: 3 s Límite de memoria: 512 MB Puntuación total: 100

#2602. 多样性街道

Estadísticas

一家建筑公司想要在一条新街道上建造 $n$ 栋房屋。为了增加城市天际线的多样性,所有房屋的高度必须互不相同,且高度均为 $1$ 到 $n$ 之间的整数。此外,还有 $m$ 条关于街道上特定区间内房屋最低高度的附加限制。由于这条新街道非常重要,市政府愿意取消其中一条限制。请确定在给定约束条件下,是否有可能制定出满足要求的街道规划。

输入格式

第一行包含两个整数:街道长度 $n$ 和高度限制数量 $m$ ($2 \le n \le 3 \cdot 10^5$, $1 \le m \le 3 \cdot 10^5$)。

接下来的 $m$ 行包含限制条件。每条限制由三个整数 $h, s, f$ 描述,表示从第 $s$ 栋到第 $f$ 栋(包含 $s$ 和 $f$)的房屋高度必须至少为 $h$ ($2 \le h \le n$, $1 \le s \le f \le n$)。

输出格式

如果无法制定出街道规划,请在单独的一行中输出 “NO”。

否则,在第一行输出 “YES”。在第二行输出一个包含 $n$ 个房屋高度的街道规划。该规划必须满足除至多一条限制外的所有限制。如果存在多种可能的规划,输出其中任意一种即可。

样例

样例输入 1

2 2
2 1 1
2 1 2

样例输出 1

YES
2 1

样例输入 2

3 2
2 1 2
2 2 3

样例输出 2

YES
1 3 2

样例输入 3

4 2
4 1 2
3 2 4

样例输出 3

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.