384. Is It a Star
A star has one centre joined to every other vertex, and no edges at all between the others. It is the shape of a hub with spokes.
Print Yes if the graph is a star and No otherwise.
Degrees decide it, and no traversal is needed. For n at least 3, a star has
exactly n - 1 edges, one vertex of degree n - 1, and every other vertex of
degree exactly 1. All three conditions are needed, and the tests are chosen to
knock out any two of them on their own.
The two smallest sizes are degenerate and the statement settles them rather
than leaving you to guess. A single vertex with no edges is a star. So is a
single edge joining two vertices, even though there both vertices have degree
n - 1 and the "exactly one centre" rule cannot pick between them.
Constraints - `1 ≤ n ≤ 100000` - `0 ≤ m ≤ 200000` - There are no self-loops and no repeated edges.
Input
The first line contains two integers n and m, the number of vertices and
edges. Each of the next m lines contains two integers u and v, an
undirected edge between those vertices. Vertices are numbered 1 to n.
Output
Print Yes or No on one line.
Hints
Four rungs, in order. The last two open once you have submitted an attempt — a wrong one counts.