#P6572. Roads Selected by Multiple Deputy Ministers
Roads Selected by Multiple Deputy Ministers
Roads Selected by Multiple Deputy Ministers
You are given a tree with n cities (numbered from 1 to n) connected by n-1 roads. Initially the cities are connected in such a way that there is exactly one simple path between any two cities.
There are m deputy ministers. Each deputy minister specifies two cities that must be connected. For a query (u, v), the deputy minister requires all the roads on the unique simple path between u and v to be chosen. For instance, if a deputy minister wants to connect cities a and c and the only path is a - b - c, then the requirement is equivalent to selecting both roads a-b and b-c.
Your task is to find all the roads that are selected by at least k deputy ministers.
Note: Roads are given in the input order and are numbered from 1 to n-1.
inputFormat
The first line contains three integers n, m and k separated by spaces.
The next n-1 lines each contain two integers u and v indicating that there is a road between cities u and v.
The next m lines each contain two integers u and v representing a deputy minister's requirement that the unique path between cities u and v should be selected.
outputFormat
On the first line output an integer r denoting the number of roads that are selected by at least k deputy ministers.
Then output r lines, each containing the index (1-indexed) of a road that satisfies the condition, in increasing order.
sample
4 3 2
1 2
2 3
2 4
1 3
3 4
1 4
3
1
2
3
</p>