21441_Granny'sBike

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

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

Pro.ID

21441

Title

Granny's Bike

Title链接

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

AC

23

Submit

42

Ratio

54.76%

时间&空间限制

  • Time Limit: 300/100 MS (Java/Others)     Memory Limit: 65536/32768 K (Java/Others)
  • 描述

    Most days Granny rides her bike around town to do errands, visit, have a cup of coffee, and so on. She enjoys riding her bike and wants to avoid passing the same place twice to add to the interest of the ride. So, each day she draws a map of the places to be visited, with lines connecting those near each other, and sees if she can visit them all and return home without passing a place more than once. Some days she finds she can do this and other days she finds she can't. For example, for the map on the left, Granny can visit every place and return home without passing any place twice, but she can't do it for the map on the right.

    She turns to you to write a program to help her.

    输入

    There will be multiple test cases for this problem. Each test case will have input on multiple lines. The first line will contain the integer n ( < 10 ) noting the number of places Granny wants to visit that day. These will be numbered 1 through n and Granny's house will be numbered 0. The next n lines will be a list of those places near each spot. The first line will be a list of places with a direct route from place 1. The second line will be a list of places with a direct route from place 2, and so on. You may assume that if place i has a direct route to place j, then there is a direct route the other direction also. A line containing 0 will follow the last test case.

    输出

    Description

    Most days Granny rides her bike around town to do errands, visit, have a cup of coffee, and so on. She enjoys riding her bike and wants to avoid passing the same place twice to add to the interest of the ride. So, each day she draws a map of the places to be visited, with lines connecting those near each other, and sees if she can visit them all and return home without passing a place more than once. Some days she finds she can do this and other days she finds she can't. For example, for the map on the left, Granny can visit every place and return home without passing any place twice, but she can't do it for the map on the right.

    She turns to you to write a program to help her.

    Input
    There will be multiple test cases for this problem. Each test case will have input on multiple lines. The first line will contain the integer n ( < 10 ) noting the number of places Granny wants to visit that day. These will be numbered 1 through n and Granny's house will be numbered 0. The next n lines will be a list of those places near each spot. The first line will be a list of places with a direct route from place 1. The second line will be a list of places with a direct route from place 2, and so on. You may assume that if place i has a direct route to place j, then there is a direct route the other direction also. A line containing 0 will follow the last test case.
    Output

    For each test case, print one line of the form:

    Case m: Granny can make the circuit.

    or

    Case m: Granny can not make the circuit.

    as appropriate. Here, m is the number of the test case, starting at 1.

    Sample Input

    5
    0 2 5
    0 1 3
    2 4
    0 3 5
    1 4
    4
    0 2 3 4
    1 3
    1 2
    0 1
    0

    Sample Output
    Case 1: Granny can make the circuit.
    Case 2: Granny can not make the circuit.
    Source

    样例输入

    5
    0 2 5
    0 1 3
    2 4
    0 3 5
    1 4
    4
    0 2 3 4
    1 3
    1 2
    0 1
    0

    样例输出

    Case 1: Granny can make the circuit.
    Case 2: Granny can not make the circuit.

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部