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:
Hà Minh Ngọc
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 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

Sample Output

YES
NO
NO

Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.