Star or Not

AtCoder
IDabc225_b
Time2000ms
Memory256MB
Difficulty
You are given a tree with $N$ vertices and $N-1$ edges. The vertices are numbered $1,2,\ldots,N$. The $i$\-th edge connects Vertex $a_i$ and Vertex $b_i$. Determine whether this tree is a star. Here, a star is a tree where there is a vertex directly connected to all other vertices. ## Constraints * $3 \leq N \leq 10^5$ * $1 \leq a_i \lt b_i \leq N$ * The given graph is a tree. ## Input Input is given from Standard Input in the following format: $N$ $a_1$ $b_1$ $\vdots$ $a_{N-1}$ $b_{N-1}$ [samples] ## Notes For the definition of a tree, see [Tree (graph theory) - Wikipedia](https://en.wikipedia.org/wiki/Tree_(graph_theory)).
Samples
Input #1
5
1 4
2 4
3 4
4 5
Output #1
Yes

The given graph is a star.
Input #2
4
2 4
1 4
2 3
Output #2
No

The given graph is not a star.
Input #3
10
9 10
3 10
4 10
8 10
1 10
2 10
7 10
6 10
5 10
Output #3
Yes
API Response (JSON)
{
  "problem": {
    "name": "Star or Not",
    "description": {
      "content": "You are given a tree with $N$ vertices and $N-1$ edges.   The vertices are numbered $1,2,\\ldots,N$. The $i$\\-th edge connects Vertex $a_i$ and Vertex $b_i$. Determine whether this tree is a star. Here",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc225_b"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given a tree with $N$ vertices and $N-1$ edges.  \nThe vertices are numbered $1,2,\\ldots,N$. The $i$\\-th edge connects Vertex $a_i$ and Vertex $b_i$.\nDetermine whether this tree is a star.\nHere...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments