AtCoder Beginner Contest 293
Ex
Optimal Path Decomposition
AtCoder
⌀ 2831
原题
←G →
翻译中…

Problem Statement

翻译中…

You are given a tree with $N$ vertices numbered $1$ through $N$. The $i$-th edge connects vertex $A_i$ and vertex $B_i$.

翻译中…

Find the minimum integer $K$ such that you can paint each vertex in a color so that the following two conditions are satisfied. You may use any number of colors.

翻译中…
  • For each color, the set of vertices painted in the color is connected and forms a simple path.
  • For all simple paths on the tree, there are at most $K$ distinct colors of the vertices in the path.
翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 2 \times 10^5$
  • $1 \leq A_i, B_i \leq N$
  • The given graph is a tree.
  • All values in the input are integers.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

N
A_1 B_1
\vdots
A_{N-1} B_{N-1}

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
7
3 4
1 5
4 5
1 2
7 4
1 6
Output #1
3
If $K=3$, the conditions can be satisfied by painting vertices $1,2,3,4$, and $5$ in color $1$, vertex $6$ in color $2$, and vertex $7$ in color $3$. If $K \leq 2$, there is no way to paint the vertices to satisfy the conditions, so the answer is $3$.
Input #2
6
3 5
6 4
6 3
4 2
1 5
Output #2
1
Input #3
9
1 3
9 5
8 7
2 1
5 2
5 8
4 8
6 1
Output #3
3
题目信息
题号
abc293_h
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。