The Partition of A Graph

Time Limit: 1000ms
Memory Limit: 32768KB
This problem will be judged on HDU. Original ID: 3097
64-bit integer IO format: %I64d      Java class name: Main

Description

Simple enough, you’ll be given a simple undirected graph with n vertexes and m edges, try to divide this graph fits the following requirements: All edges are divided into several groups; only two edges exist in every group, and this two edges have common vertex.
Your task is to figure out if such a partition exists.

Input

There are multiple test cases, for each test case:
The first line contains two integers n (0<n<=1000) and m represent the number of vertexes and edges.
The following m lines, each line contains two integers represent two endpoints of an edge.
The vertexes are numbered from 1 to n.
The input terminated when n=m=0.

Output

For each test case, output one line, if such a partition exists, print “Yes”, otherwise, print “No”.

Sample Input

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

Sample Output

No
Yes

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .