传统题 1000ms 512MiB

A Problem on the Tree

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Description

You have a tree with nn vertices. You also have a starting vertex ss on this tree.

You need to start from vertex ss and take at most kk steps. At each step, you can move to any adjacent vertex. You want to know how many different vertices can you pass through at most. (Including the starting vertex ss)

Input

First line has three integers, n,s,kn,s,k.

Next, we have n1n-1 lines. Each line contains two intergers ui,viu_i,v_i, means there has an edge between vertex uiu_i and viv_i.

Output

One line with one integer, means the maximum number of different vertices that can be passed through.

Sample Input

5 1 4
1 2
1 3
1 4
4 5

Sample Output

4

Tips

The figure shows a feasible solution. Take 44 steps, passed through 44 different vertices.

数据范围

1sn1061\leq s\leq n\leq 10^6

1k2×1061\leq k\leq 2\times 10^6

Hello ACM 2026

未参加
状态
已结束
规则
ACM/ICPC
题目
13
开始于
2026-8-15 13:00
结束于
2026-8-15 18:00
持续时间
5 小时
主持人
参赛人数
31