eolymp
bolt
Try our new interface for solving problems
Problems

Transitivity of a graph

Transitivity of a graph

Undirected graph without loops and multiple edges is called \textit{transitive}, if from conditions that vertices $u$ and $v$ are connected with an edge, vertices $v$ and $w$ are connected with an edge and all three vertices $u, v$ and $w$ are different, implies that vertices $u$ and $w$ are connected with an edge. Verify that a given undirected graph is transitive. \InputFile The first line contains the number of vertices $n$ and edges $m~(3 \le n \le 100, 0 \le m \le (n \cdot (n - 1)) / 2)$ of the graph. Then $m$ lines are given - the list of edges. \OutputFile Print "\textbf{YES}" or "\textbf{NO}" --- the answer to the question about transitivity of a graph. \includegraphics{https://static.e-olymp.com/content/44/448c3c30c5ca7c7a3fc13bae655351913d9a22fb.gif}
Time limit 1 second
Memory limit 128 MiB
Input example #1
3 3
1 2
2 3
1 3
Output example #1
YES
Input example #2
3 2
1 2
1 3
Output example #2
NO