eolymp
bolt
Try our new interface for solving problems
Problems

Find Permutation

Find Permutation

There is a length $n$ sequence $A = (a_1, a_2, ..., a_n)$​ that is a permutation of $1, 2, ..., n$. While you do not know $A$, you know that $A_{x_i} < A_{y_i}$ for $m$ pairs of integers $(x_i, y_i)$. Can $A$ be uniquely determined? If it is possible, find $A$. \InputFile The first line contains two numbers $n\:(2 \le n \le 2 \cdot 10^5)$ and $m\:(1 \le m \le 2 \cdot 10^5)$. Each of the next $m$ lines contains a pair of integers $(x_i, y_i)$, $1 \le x_i, y_i \le n$. \OutputFile If $A$ can be uniquely determined, print \textbf{Yes} in the first line. Then, print $a_1, a_2, ..., a_n$ in the second line. If $A$ cannot be uniquely determined, just print \textbf{No}.
Time limit 1 second
Memory limit 128 MiB
Input example #1
4 4
3 1
3 4
1 4
4 2
Output example #1
Yes
2 4 1 3 
Input example #2
4 4
3 4
1 4
1 2
4 2
Output example #2
No