1531_CanIPosttheletter

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

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

Pro.ID

1531

Title

Can I Post the letter

Title链接

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

AC

9

Submit

12

Ratio

75.00%

时间&空间限制

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

    I am a traveler. I want to post a letter to Merlin. But because there are so many roads I can walk through, and maybe I can’t go to Merlin’s house following these roads, I must judge whether I can post the letter to Merlin before starting my travel. 

    Suppose the cities are numbered from 0 to N-1, I am at city 0, and Merlin is at city N-1. And there are M roads I can walk through, each of which connects two cities. Please note that each road is direct, i.e. a road from A to B does not indicate a road from B to A.

    Please help me to find out whether I could go to Merlin’s house or not.

    输入

    There are multiple input cases. For one case, first are two lines of two integers N and M, ( N <= 200, M <= N*N/2 ), that means the number of cities and the number of roads. And Merlin stands at city N-1. After that, there are M lines. Each line contains two integers i and j, what means that there is a road from city i to city j.

    The input is terminated by N=0.

    输出

    Description

    I am a traveler. I want to post a letter to Merlin. But because there are so many roads I can walk through, and maybe I can’t go to Merlin’s house following these roads, I must judge whether I can post the letter to Merlin before starting my travel. 

    Suppose the cities are numbered from 0 to N-1, I am at city 0, and Merlin is at city N-1. And there are M roads I can walk through, each of which connects two cities. Please note that each road is direct, i.e. a road from A to B does not indicate a road from B to A.

    Please help me to find out whether I could go to Merlin’s house or not.

    Input

    There are multiple input cases. For one case, first are two lines of two integers N and M, ( N <= 200, M <= N*N/2 ), that means the number of cities and the number of roads. And Merlin stands at city N-1. After that, there are M lines. Each line contains two integers i and j, what means that there is a road from city i to city j.

    The input is terminated by N=0.

    Output
    For each test case, if I can post the letter print "I can post the letter" in one line, otherwise print "I can't post the letter".
    Sample Input
    3
    2
    0 1
    1 2
    3
    1
    0 1
    0
    Sample Output
    I can post the letter
    I can't post the letter

    样例输入

    3
    2
    0 1
    1 2
    3
    1
    0 1
    0

    样例输出

    I can post the letter
    I can't post the letter

    提示

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部