Codeforces Round 408 (Div. 2)
D
Police Stations
Codeforces
2100
原题
← CE →
翻译中…

Inzane finally found Zane with a lot of money to spare, so they together decided to establish a country of their own.

翻译中…

Ruling a country is not an easy job. Thieves and terrorists are always ready to ruin the country's peace. To fight back, Zane and Inzane have enacted a very effective law: from each city it must be possible to reach a police station by traveling at most $*d*$ kilometers along the roads.

翻译中…

image

翻译中…

There are $*n*$ cities in the country, numbered from $1$ to $*n*$, connected only by exactly $*n* - 1$ roads. All roads are $1$ kilometer long. It is initially possible to travel from a city to any other city using these roads. The country also has $*k*$ police stations located in some cities. In particular, the city's structure satisfies the requirement enforced by the previously mentioned law. Also note that there can be multiple police stations in one city.

翻译中…

However, Zane feels like having as many as $*n* - 1$ roads is unnecessary. The country is having financial issues, so it wants to minimize the road maintenance cost by shutting down as many roads as possible.

翻译中…

Help Zane find the maximum number of roads that can be shut down without breaking the law. Also, help him determine such roads.

翻译中…

Input

翻译中…

The first line contains three integers $*n*$, $*k*$, and $*d*$ ($2 ≤ *n* ≤ 3·10^{5}$, $1 ≤ *k* ≤ 3·10^{5}$, $0 ≤ *d* ≤ *n* - 1$) — the number of cities, the number of police stations, and the distance limitation in kilometers, respectively.

翻译中…

The second line contains $*k*$ integers $*p*_{1}, *p*_{2}, ..., *p*_{*k*}$ ($1 ≤ *p*_{*i*} ≤ *n*$) — each denoting the city each police station is located in.

翻译中…

The $*i*$-th of the following $*n* - 1$ lines contains two integers $*u*_{*i*}$ and $*v*_{*i*}$ ($1 ≤ *u*_{*i*}, *v*_{*i*} ≤ *n*$, $*u*_{*i*} ≠ *v*_{*i*}$) — the cities directly connected by the road with index $*i*$.

翻译中…

It is guaranteed that it is possible to travel from one city to any other city using only the roads. Also, it is possible from any city to reach a police station within $*d*$ kilometers.

翻译中…

Output

翻译中…

In the first line, print one integer $*s*$ that denotes the maximum number of roads that can be shut down.

翻译中…

In the second line, print $*s*$ distinct integers, the indices of such roads, in any order.

翻译中…

If there are multiple answers, print any of them.

翻译中…

Note

翻译中…

In the first sample, if you shut down road $5$, all cities can still reach a police station within $*k* = 4$ kilometers.

翻译中…

In the second sample, although this is the only largest valid set of roads that can be shut down, you can print either 4 5 or 5 4 in the second line.

翻译中…

样例

Input #1
6 2 4
1 6
1 2
2 3
3 4
4 5
5 6
Output #1
1
5
InputCopy OutputCopy
Input #2
6 3 2
1 5 6
1 2
1 3
1 4
1 5
5 6
Output #2
2
4 5
InputCopy OutputCopy
题目信息
题号
796D
时间限制
2 s
内存限制
256 MB
标签
构造
DFS 及类似
动态规划
图论
最短路
树

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