Submit | All submissions | Best solutions | Back to list |
EICHTTRE - Is tree |
Given a graph of n vertices and m edges. Check if the given graph is a tree.
Input:
The first line contains the number of T test cases (T <100).
Each testc case includes:
- The first line contains two positive integers, the number of vertices n (0 < n < 105) và m edges( m <= 2 x 105)
- Then there are m lines, each containing two positive integers u and v (u,v < 105) representing an edge between node u and node v
Output:
Include T lines corresponding to the number of test cases, if the graph is a tree, print "YES" and print "NO" otherwise.
Sample:
Input :
3
6 5
0 1
0 2
1 5
2 4
2 3
5 5
0 1
0 2
1 3
3 1
3 4
4 3
0 1
1 3
0 3
Output:
YES
NO
NO
Added by: | Ha Minh Ngoc |
Date: | 2016-01-04 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | CSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG FSHARP GO JAVA JS-MONKEY NODEJS PHP PYTHON PYPY PYPY3 PYTHON3 RUBY SQLITE SWIFT VB.NET |