QOJ.ac

QOJ

Time Limit: 5.0 s Memory Limit: 1024 MB Total points: 100 Hackable ✓

#15231. The Promise of Photinia

Statistics

Rigel hates stone flowers, especially in the spring, as the "fragrance" of the stone flowers blooming in Wuhan makes him unable to stay away.

It is unfortunate that when Rigel meets his girlfriend, he is horrified to smell the stone flowers! The location of Rigel's date can be viewed as a tree structure containing $n$ nodes, and there are $m$ stone flowers blooming on this tree. Now he only wants to take his girlfriend to a place as far away from the stone flowers as possible, otherwise, he will be embarrassed in front of his girlfriend.

Fortunately, because he hates stone flowers so much, Rigel has awakened a special ability: he can remove the stone flowers from at most $k$ nodes on this tree, allowing him to stay as far away from the stone flowers as possible.

Specifically, you need to remove the stone flowers from $k$ nodes. Let the remaining nodes with stone flowers be $x_1, x_2, \dots, x_{m-k}$. You need to maximize $\max_{i=1}^n \{ \min_{j=1}^{m-k} dis(i, x_j) \}$, where $dis(x, y)$ denotes the distance between node $x$ and node $y$.

Input

The first line contains three integers $n, m, k$ ($1 \le m \le n \le 10^5, 0 \le k < m$).

The next $n-1$ lines each contain two integers $u, v$ ($1 \le u, v \le n$), representing an edge $(u, v)$ on the tree.

The next line contains $m$ integers $a_i$ ($1 \le a_i \le n$), representing the nodes occupied by stone flowers. It is guaranteed that all $a_i$ are distinct.

Output

Output one integer, the maximum distance Rigel can achieve from the remaining stone flowers.

Examples

Input 1

7 3 1
1 2
1 3
2 4
3 5
3 6
5 7
3 4 5

Output 1

3

Note

If you remove the stone flower at node 4, the nodes on the tree furthest from the remaining stone flowers are at node 4, with a distance of 3. It can be proven that this method is unique.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.