21758_Courier'sRoute

2022-5-16 18:20| 发布者: Hocassian| 查看: 21| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-89505822357799-Problem List-采集的数据-后羿采集器.html

Pro.ID

21758

Title

Courier's Route

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21758

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    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 ≤ iN) 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 ≤ iN) 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
    9
    2 10
    3 13
    4 8
    5 11
    6 14
    7 16
    15 12

    Sample Output

    Yes
    1 3 13 14 16 15 12 9 10 11 5 6 7 8 4 2

    Source

    样例输入

    41
    9
    2 10
    3 13
    4 8
    5 11
    6 14
    7 16
    15 12

    样例输出

    Yes
    1 3 13 14 16 15 12 9 10 11 5 6 7 8 4 2

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部