#P3698. [CQOI2017] 小Q的棋盘
[CQOI2017] 小Q的棋盘
Description
Xiao Q is designing a board game.
In the game he designed, pieces can be placed on the grid points on the board. Some pairs of grid points are connected by lines, and a piece may move only between grid points that are connected by a line. There are grid points in total, labeled , and they are connected; that is, starting from any grid point, the piece can reach all grid points. Xiao Q also guarantees that the path between any two grid points is unique.
Xiao Q now wants to know: starting from grid point , after moving steps, what is the maximum number of grid points that can be visited? A grid point may be visited multiple times, but is counted only once.
Input Format
The first line contains positive integers , where is the total number of grid points and is the number of moves.
Each of the next lines contains two integers , indicating that there is a line connecting grid points and .
Output Format
Output a single integer, the maximum number of grid points that can be visited.
5 2
1 0
2 1
3 2
4 3
3
9 5
0 1
0 2
2 6
4 2
8 1
1 3
3 7
3 5
5
Hint
[Explanation for Sample 1]
From grid point , move steps. The piece visits , i.e., grid points.
[Explanation for Sample 2]
One feasible path is , visiting , i.e., grid points.
Constraints
For of the testdata, , and .
Translated by ChatGPT 5
京公网安备 11011102002149号