CF796D.Police Stations

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 dd kilometers along the roads.

There are nn cities in the country, numbered from 11 to nn , connected only by exactly n1n-1 roads. All roads are 11 kilometer long. It is initially possible to travel from a city to any other city using these roads. The country also has kk 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 n1n-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.

输入格式

The first line contains three integers nn , kk , and dd ( 2<=n<=31052<=n<=3·10^{5} , 1<=k<=31051<=k<=3·10^{5} , 0<=d<=n10<=d<=n-1 ) — the number of cities, the number of police stations, and the distance limitation in kilometers, respectively.

The second line contains kk integers p1,p2,...,pkp_{1},p_{2},...,p_{k} ( 1<=pi<=n1<=p_{i}<=n ) — each denoting the city each police station is located in.

The ii -th of the following n1n-1 lines contains two integers uiu_{i} and viv_{i} ( 1<=ui,vi<=n1<=u_{i},v_{i}<=n , uiviu_{i}≠v_{i} ) — the cities directly connected by the road with index ii .

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 dd kilometers.

输出格式

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

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

If there are multiple answers, print any of them.

输入输出样例

  • 输入#1

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

    输出#1

    1
    5
    
  • 输入#2

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

    输出#2

    2
    4 5 

说明/提示

In the first sample, if you shut down road 55 , all cities can still reach a police station within k=4k=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.

首页