• 1906 Message System

    时间限制 : 16000/8000 MS(Java/Others) | 内存限制 : 131072/65536 KB(Java/Others)

    提交数 : 17 | 通过数 : 8

    题目描述

    Little Kawaii has built a simple message system to process the Academy Cute Message(ACM). The message system consists of many endpoints, which are connected by message channels. The messages can only pass across the channels, and will be originated at any endpoint. When receiving or originating a message, each endpoint will process the message then send the message to the channels that it connects to, except the one from which the message comes. In case the endpoint is the originator, the message will be send to all the channels it connects to. Academy Cute Message is very important, so if any message is generated, it requires that all endpoints will receive it properly. However, processing the message requires tremendous resources, so Little Kawaii hopes that the endpoints will not receive duplicated messages. Given the description of the message system, Little Kawaii asks you to write a program to determine whether the system could fulfill the requirements.

    输入要求

    The input consists of several test cases, separated by a blank line. Each case starts with 2 integer N and M, separated by white spaces. N represents the number of endpoints in the system, 1 <= N <= 1000; 0 <= M <= N * (N - 1) / 2. Then M lines of input follows, each consists of 2 integer A and B, separated by white spaces, 1 <= A, B <= N, meaning there is a message channel between endpoint A and B. There will be at most one channel between two endpoints, and there is no channel connects an endpoint to itself. A test case starting with two 0(zero) signals the end of the input, you should not process it.

    输出要求

    For each test case, output "Yes" in a single line, if the message system fulfills Little Kawaii's requirements, otherwise output "No" in a single line.

    输入样例

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

    输出样例

    Yes
    No
    

    提示


    来源

    ZOJ   YANG, Chao

    [ 返回顶端 ] | [ 代码提交 ] | [ 统计数据 ] | [ 历史提交 ]