Tree - MarisaOJ: Marisa Online Judge

Tree

Time limit: 1000 ms
Memory limit: 256 MB
Given a graph of $n$ vertices and $m$ edges. Determine whether or not the given graph is a tree. ### Input - The first line contains 2 integers $n, m$. - The next $n$ lines, each line contains 2 integers $u, v$, there is an edge between $u$ and $v$. ### Output - Print `YES` if the graph is a tree, `NO` otherwise. ### Constraints - $1 \le n, m \le 10^5$. - $1 \le u, v \le n$. ### Example Input: ``` 6 5 1 2 2 3 3 4 4 5 5 6 ``` Output: ``` YES ```