Pro.ID21758 TitleCourier's Route Title链接http://10.20.2.8/oj/exercise/problem?problem_id=21758 AC0 Submit0 Ratio- 时间&空间限制描述There are N towns in a kingdom, numbered from 1 to N, with the capital having the number 1. Each town is enclosed in a city wall with 4 gates. The gates are also numbered, with the gates of the city i (1 ≤ i ≤ N) numbered 4*i-3, 4*i-2, 4*i-1, 4*i. At each gate is exactly one road that leads to some gate of another town (note that there may be more than one road between two towns). All the roads can be travelled in both directions. Due to a system of bridges and tunnels, the roads do not intersect outside the towns. A royal courier has to post copies of an Important Royal Decree on the outer sides of all gates of all towns. The courier can freely move from one gate to another in any town, but outside of towns, he's allowed to travel only along the roads. The courier starts from the capital and has to return to the capital after completing the assignment. Is it possible for the courier to do this, passing each gate exactly once? Exiting a town through a gate only to post the decree on the outer side of the gate and immediately returning to the town counts as passing the gate once. 输入The first line of the input file contains N (2 ≤ N ≤ 1000). Each of the following 2*N lines describes one road and contains two integers, separated by a space: the numbers of the two gates connected by the road. 输出Description There are N towns in a kingdom, numbered from 1 to N, with the capital having the number 1. Each town is enclosed in a city wall with 4 gates. The gates are also numbered, with the gates of the city i (1 ≤ i ≤ N) numbered 4*i-3, 4*i-2, 4*i-1, 4*i. At each gate is exactly one road that leads to some gate of another town (note that there may be more than one road between two towns). All the roads can be travelled in both directions. Due to a system of bridges and tunnels, the roads do not intersect outside the towns. A royal courier has to post copies of an Important Royal Decree on the outer sides of all gates of all towns. The courier can freely move from one gate to another in any town, but outside of towns, he's allowed to travel only along the roads. The courier starts from the capital and has to return to the capital after completing the assignment. Is it possible for the courier to do this, passing each gate exactly once? Exiting a town through a gate only to post the decree on the outer side of the gate and immediately returning to the town counts as passing the gate once. Input The first line of the input file contains N (2 ≤ N ≤ 1000). Each of the following 2*N lines describes one road and contains two integers, separated by a space: the numbers of the two gates connected by the road. Output The first line of the output le should contain the word "Yes" or "No" (without the quotes) depending on whether the courier's assignment can be completed while passing each gate exactly once. In case it is possible, the second line of the file should contain 4*N integers, separated by spaces: the numbers of the gates in the order the courier passes them. If there are several solutions, output any one of them. Sample Input 41 Sample Output Yes Source 样例输入41 样例输出Yes 作者 |