AtCoder Regular Contest 211 (Div. 2)
D
Michishirube
AtCoder
⌀ 2301
原题
← CE →
翻译中…

Problem Statement

翻译中…

You are given a simple connected undirected graph with $N$ vertices and $M$ edges. The $i$-th edge $(1\leq i\leq M)$ is an undirected edge connecting vertices $U_i$ and $V_i$.

翻译中…

Place signposts at all vertices as follows:

翻译中…
  • At every vertex except vertex $1$, place a blue signpost pointing to one of its adjacent vertices.
  • At every vertex except vertex $2$, place a yellow signpost pointing to one of its adjacent vertices.
翻译中…

Here, the two signposts at the same vertex must not point to the same vertex.

翻译中…

Determine whether it is possible to place signposts satisfying the following conditions, and if possible, output one way to place them:

翻译中…
  • From any vertex other than vertex $1$, you can reach vertex $1$ by repeatedly moving to the vertex pointed to by the blue signpost a finite number of times.
  • From any vertex other than vertex $2$, you can reach vertex $2$ by repeatedly moving to the vertex pointed to by the yellow signpost a finite number of times.
翻译中…

If there are multiple ways to place signposts satisfying the conditions, you may output any of them.

翻译中…

Constraints

翻译中…
  • $2\leq N\leq 2\times 10^5$
  • $1\leq M\leq 3\times 10^5$
  • $1\leq U_i\lt V_i\leq N$ $(1\leq i\leq M)$
  • The given graph is simple and connected.
  • All input values are integers.
翻译中…

Input

翻译中…

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

翻译中…

N M
U_1 V_1
U_2 V_2
\vdots
U_M V_M

翻译中…

Output

翻译中…

If there is no way to place signposts satisfying the conditions, output No only.

翻译中…

If there is, output $N+1$ lines.

翻译中…

The first line should contain Yes.

翻译中…

The second line should contain the number of the vertex pointed to by the yellow signpost at vertex $1$.

翻译中…

The third line should contain the number of the vertex pointed to by the blue signpost at vertex $2$.

翻译中…

The $i$-th line $(4\leq i\leq N+1)$ should contain the number of the vertex pointed to by the blue signpost at vertex $i-1$ and the number of the vertex pointed to by the yellow signpost at vertex $i-1$, in this order, separated by a space.

翻译中…

If there are multiple solutions, you may output any of them.

翻译中…

样例

Input #1
7 8
1 3
3 4
4 5
1 5
4 6
2 6
2 7
4 7
Output #1
Yes
5
6
4 1
5 6
1 4
4 2
4 2
Here, signposts are placed as shown in the figure below. For example, from vertex $3$: - Following the blue signpost, you move as vertex $3\rightarrow 4\rightarrow 5\rightarrow 1$, eventually reaching vertex $1$. - Following the yellow signpost, you move as vertex $3\rightarrow 1\rightarrow 5\rightarrow 4 \rightarrow 6\rightarrow 2$, eventually reaching vertex $2$. You can also verify that following the blue signpost from vertex $2$ leads to vertex $1$, and following the yellow signpost from vertex $1$ leads to vertex $2$. The other vertices also satisfy the conditions. ![image](https://img.atcoder.jp/arc211/b14d7aa0532d37600cd141d8f5f7f695.png) There are multiple other solutions, but you must not have both the blue signpost and the yellow signpost at vertex $3$ point to vertex $4$, because the signposts at the same vertex would point to the same vertex.
Input #2
10 12
1 3
3 4
4 5
1 5
4 6
2 6
2 7
4 7
4 8
8 9
9 10
8 10
Output #2
No
There is no way to place signposts satisfying the conditions.
题目信息
题号
arc211_d
时间限制
2 s
内存限制
1024 MB

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