Sunny Graph
Time limit3sMemory limit512 MB
Given a graph with an odd number of vertices, decide whether vertex 1 lies on a cycle of three or more vertices while all other vertices pair up into disjoint edges.
- Level
Medium7 of 10
- Topics
- Graph, Implementation
- Solved
- No attempts yet
Problem
The Sun is a great heavenly body, and many religions worship it. Bob loves the Sun and loves any object that is similar to the Sun. He noticed that he can find the shape of the Sun in certain graphs, and he calls such graphs "Sunny".
A graph with a vertex is called "Sunny" when there exists a subgraph that has the following two properties. The set of vertices must be the same as .
- The connected component containing is a cycle that consists of three or more vertices.
- Every other component has exactly two vertices.
The following picture is an example of a subgraph that has the above property.

Given a simple graph , write a program that decides whether the given graph with vertex is "Sunny".
Input
The first line contains two integers (odd, ) and (), separated by a single space. is the number of vertices and is the number of edges.
The following lines describe the edges. Each line contains two integers and (), which means that the edge connects vertices and . and are different, and every pair is different.
Output
Print a line containing "Yes" when the graph is "Sunny". Otherwise, print "No".