LearnPy Hub
← Arena
IntermediateRating 1300

Is the Graph a Tree?

An undirected graph has n nodes and m edges. Print YES if it is a tree (connected and without loops), otherwise NO.

Input

n and m; then m lines 'u v'.

Output

YES or NO.

Sample 1

Input
5 4
1 2
1 3
1 4
4 5
Output
YES

Sample 2

Input
4 3
1 2
2 3
3 1
Output
NO
solution.py
Output appears here
Is the Graph a Tree? · Python Arena problem · LearnPy Hub