#abc225b. B - Star or Not
B - Star or Not
Score : points
问题描述
给定一棵包含 个顶点和 条边的树。 顶点编号为 。第 条边连接顶点 和顶点 。
判断此树是否为星形树。
这里,星形树指的是一棵树中存在一个顶点直接与所有其他顶点相连。
以上为通义千问 qwen-max 翻译,仅供参考。
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
.
Sample Input 1
5
1 4
2 4
3 4
4 5
Sample Output 1
Yes
The given graph is a star.
Sample Input 2
4
2 4
1 4
2 3
Sample Output 2
No
The given graph is not a star.
Sample Input 3
10
9 10
3 10
4 10
8 10
1 10
2 10
7 10
6 10
5 10
Sample Output 3
Yes
update @ 2024/3/10 09:52:49