EICHTTRE - Is tree ?
Xem dạng PDF
Gửi bài giải
Điểm:
1,00 (OI)
Giới hạn thời gian:
1.0s
Giới hạn bộ nhớ:
256M
Input:
stdin
Output:
stdout
Nguồn bài:
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch
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 \le 100)~.
- Each testc case includes:
- The first line contains two positive integers, the number of vertices ~n~ ~(n \le 10^5)~ và ~m~ edges ~(m \le 2 \times 10^5)~
- Then there are ~m~ lines, each containing two positive integers ~u~ and ~v~ ~(u,v \le 10^5)~ 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
YESand printNOotherwise.
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
Sample Output
YES
NO
NO
Bình luận