AtCoder Regular Contest 205 (Div. 2)
C
No Collision Moves
AtCoder
⌀ 1381
原题
← BD →
翻译中…

Problem Statement

翻译中…

There are $N$ people on a number line.

翻译中…

Person $i$ $(1\le i\le N)$ is initially at coordinate $S_i$, and wants to eventually move to coordinate $T_i$. It is guaranteed that $S_1,S_2,\ldots,S_N,T_1,T_2,\ldots,T_N$ are all distinct.

翻译中…

You fix one permutation $P=(P_1,P_2,\ldots,P_N)$ of $(1,2,\ldots,N)$ and perform $N$ operations in order. In the $i$-th operation $(1\le i\le N)$, you move person $P_i$ from coordinate $S_{P_i}$ to coordinate $T_{P_i}$ along the shortest path on the number line. However, if there is another person on the movement path, a fight occurs.

翻译中…

Determine if there exists a $P$ such that no fight occurs, and if it exists, find one.

翻译中…

Constraints

翻译中…
  • $1\le N\le 2\times 10^5$
  • $1\le S_i, T_i \le 10^9$
  • $S_1,S_2,\ldots,S_N,T_1,T_2,\ldots,T_N$ are all distinct.
  • All input values are integers.
翻译中…

Input

翻译中…

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

翻译中…

N
S_1 T_1
S_2 T_2
\vdots
S_N T_N

翻译中…

Output

翻译中…

If there is no $P$ such that no fight occurs, output No.

翻译中…

Otherwise, output a $P$ such that no fight occurs in the following format.

翻译中…

Yes
P_1 P_2 \ldots P_N

翻译中…

If there are multiple $P$ that satisfy the condition, any of them will be accepted.

翻译中…

样例

Input #1
4
1 3
2 4
7 5
8 10
Output #1
Yes
3 2 1 4
If $P=(3,2,1,4)$, then the $N$ operations proceed as follows. - $1$st operation: Move person $3$ from coordinate $7$ to coordinate $5$. The other three people are at coordinates $1,2,8$, so no fight occurs. - $2$nd operation: Move person $2$ from coordinate $2$ to coordinate $4$. The other three people are at coordinates $1,5,8$, so no fight occurs. - $3$rd operation: Move person $1$ from coordinate $1$ to coordinate $3$. The other three people are at coordinates $4,5,8$, so no fight occurs. - $4$th operation: Move person $4$ from coordinate $8$ to coordinate $10$. The other three people are at coordinates $3,4,5$, so no fight occurs. Therefore, outputting $P=(3,2,1,4)$ will be accepted. Other acceptable outputs include $P=(4,3,2,1),(2,1,3,4)$.
Input #2
2
1 3
4 2
Output #2
No
There is no $P$ such that no fight occurs. Therefore, output `No`.
Input #3
5
19 17
1 10
9 14
3 11
8 13
Output #3
Yes
3 5 1 4 2
题目信息
题号
arc205_c
时间限制
3 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。