atcoder#ABC225B. [ABC225B] Star or Not
[ABC225B] Star or Not
Score : points
Problem Statement
You are given a tree with vertices and edges. The vertices are numbered . The -th edge connects Vertex and Vertex .
Determine whether this tree is a star.
Here, a star is a tree where there is a vertex directly connected to all other vertices.
Notes
For the definition of a tree, see Tree (graph theory) - Wikipedia
.
Constraints
- The given graph is a tree.
Input
Input is given from Standard Input in the following format:
Output
If the given graph is a star, print Yes
; otherwise, print No
.
5
1 4
2 4
3 4
4 5
Yes
The given graph is a star.
4
2 4
1 4
2 3
No
The given graph is not a star.
10
9 10
3 10
4 10
8 10
1 10
2 10
7 10
6 10
5 10
Yes