#P12452. [INOI Team Selection 2021] Color Colony

[INOI Team Selection 2021] Color Colony

题目描述

A path is bad if and only if the colors of all edges in it are different, otherwise, the path is good.

A tree is bad if and only if there exists a path of length kk in it which is bad, otherwise, the tree is good.

Now we have a tree, we want to color its edges, the beauty of coloring of edges is the number of different colors we use, we want to make the beauty of coloring maximum possible, and we don't want our tree to become bad, what is maximum beauty we can reach?

输入格式

The first line of the input contains nn and kk, the number of vertices of the tree, and the value kk which declares we shouldn't have a bad path of length kk in tree.

The following n1n-1 lines describe the edges of the tree. The ii-th line contains two integers uu and vv, denotes an edge between uu and vv. It is guaranteed that these edges form a tree.

输出格式

Print one integer, the maximum number of colors we can use.

4 2
1 2
1 3
1 4
1
6 3
1 2
2 3
3 4
4 5
5 6
3
11 3
1 8
1 7
1 3
1 2
2 11
2 10
2 9
3 5
3 4
3 6
7

提示

Constraints

  • 2kn1052 \leq k \leq n \leq 10^5
  • 2k302 \leq k \leq 30

Subtask

subtask score limits
1 19 degree of each vertex in the tree is at most 3.
2 7 n10n \leq 10
3 18 n30n \leq 30, k10k \leq 10
4 22 n100n \leq 100
5 25 n50000n \leq 50000
6 9 No extra limits