CF981C Useful Decomposition

题目描述

### 【题目大意】: `Ramesses`了解了很多跟树(就是`OI`里的树)相关的知识。 现在,`Ramesses`发明了一种树的分解,不过他还不知道如何去分解一棵树,所以您需要帮他分解。 所谓`树的分解`,就是把树分解成好几条链,使得每条边都**在且仅在**一条链上,而且任意两条链都有**至少一个**公共点。 请您帮助`Ramesses`,找到一种可行的`树的分解`或确定无解。 -------------------------------

输入格式

第一行,只有一个整数$n(2\leq n\leq 1\times 10^5)$,表示这棵树的节点个数。 第$2$到第$n+1$行,每行两个整数$u,v$,表示树上有一条边,直接链接点$(u,v)$。 **输入保证无误(即输入一定是一棵树)。** --------------------------------------

输出格式

如果无解,则输出`No`,程序输出完毕。 如果有解,先输出一行`Yes`。然后在第$2$行中输出一个整数$m$,表示您把输入的树划分成了$m$条链。 接下来$m$行,输出两个整数$u_i,v_i(1 \leq u_i,v_i \leq n,u_i \neq v_i)$,表示每条链的起点和终点。 任意两对输出应该有**至少一个**公共点,树中的**每一条边都应该包含在输出中**,注意,**不能有两条链同时包括一条边!** 如果有多组解,输出任意一组即可(所以本题有`SPJ`)!!! ------------------------------------- ### 【样例解释】: 如图,每条边上的数字$T$代表该边被划分到第$T$条链上。第$2$组样例无解。 ---------------------------- ```cpp Translated by HPXXZYY! ```

说明/提示

The tree from the first example is shown on the picture below: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF981C/ac84a1817ecb1ae8f7e08f7dfa37e5d3eca6d1b6.png) The number next to each edge corresponds to the path number in the decomposition. It is easy to see that this decomposition suits the required conditions. The tree from the second example is shown on the picture below: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF981C/337aa5a9c085354e639d58826e5e3194b32cad26.png) We can show that there are no valid decompositions of this tree. The tree from the third example is shown on the picture below: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF981C/0e12f8fa1f6666b81e8b3fb6bdc07e453037ae5d.png) The number next to each edge corresponds to the path number in the decomposition. It is easy to see that this decomposition suits the required conditions.