really likes the organic compound xylene, also known as dimethylbenzene. He has received an organic molecule as a present, and would like to know if there exists a dimethylbenzene somewhere in it.
However, organic chemistry is a struggle for
, so he'll settle for knowing whether or not his molecule contains six carbons atoms arranged in a ring, or cycle. There may be multiple cycles in 's present, but he's only interested in finding out if there is at least one that is six atoms long.Does his present contain at least one cycle of length six?
Input Specification
The first line of input will contain two space-separated integers
The next
Output Specification
YES
if the given molecule contains a cycle that is six carbon atoms long, NO
otherwise.
Sample Input 1
Copy
6 6
1 2
2 3
3 4
4 5
5 6
6 1
Sample Output 1
Copy
YES
Explanation for Sample 1
This is a ring of six carbons:
Sample Input 2
Copy
3 3
1 2
2 3
3 1
Sample Output 2
Copy
NO
Explanation for Sample 2
Though this may be a cycle, it is only of length three.
Sample Input 3
Copy
2 1
1 2
Sample Output 3
Copy
NO
Explanation of Sample 3
This is not a cycle!
Sample Input 4
Copy
8 8
1 2
2 3
3 4
4 5
5 6
6 1
6 7
7 8
Sample Output 4
Copy
YES
Sample Input 5
Copy
8 9
1 2
2 3
3 4
4 5
5 6
6 1
6 7
7 8
8 1
Sample Output 5
Copy
YES
Comments
can there be lines in between the circles? what would this output: 6 7 1 2 2 3 3 4 4 5 5 6 6 1 1 4
I noticed that the ladderane structure is possible, but I'm confused on whether a ladderane contains a 'simple cycle' of length 6.
Example Case:
What is the proper answer? Do the AC submissions disagree over this?
aren't the carbon atoms supposed to be placed in increasing order?
1 2, 2 3, 3 5, 5 6, 6 4, and 4 1 gives a simple cycle of length 6.
Cycle means simple cycle)