Cliques Y16864


Statement
 

pdf   zip

Given an undirected graph with nn vertices and mm edges, tell whether every connected component is a clique, that is, if all the vertices of the component are directly connected to each other.

Input

Input consists of several cases. Each case begins with nn and mm, followed by mm pairs xx yy, with xyx \ne y, indicating an edge between xx and yy. Suppose 1n1051 \le n \le 10^5, 0m5n0 \le m \le 5n, that the vertices are numbered between 0 and n1n-1, and that there are no repeated edges.

Output

For each given graph, print “SI” if every connected component is a clique, and “NO” otherwise.

Observation

Even if a green light is obtained, only solutions that perform a single graph traversal will receive the maximum score.

Public test cases
  • Input

    6 4
    0 1  2 1  2 0  3 5
    
    6 6
    0 5  1 2  2 3  3 4  4 1  2 4
    

    Output

    SI
    NO
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Salvador Roura
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++