#P2495. 【模板】虚树 / [SDOI2011] 消耗战
【模板】虚树 / [SDOI2011] 消耗战
Description
In a war, the battlefield consists of islands connected by bridges, and there is exactly one simple path between any two islands. Our intelligence has located the enemy headquarters on island . The enemy lacks sufficient energy to sustain combat, and victory is in sight. It is known that there are rich energy reserves on another islands. To prevent the enemy from obtaining energy, our task is to blow up some bridges so that the enemy cannot reach any energy-rich island from island . Since different bridges have different materials and structures, the cost to destroy each bridge varies. We want to minimize the total cost while achieving the objective.
Intelligence also found that the enemy has a mysterious machine. Even after we cut off all energy, they can use that machine. The machine will not only repair all bridges we blew up, but also randomly redistribute the energy (with the guarantee that no energy will be placed on island ). However, the machine can be used only times, so we only need to complete the task for each use.
Input Format
The first line contains an integer , the number of islands.
The next lines each contain three integers , indicating that islands and are directly connected by a bridge with destruction cost .
The -th line contains an integer , the number of times the enemy can use the machine.
Then follow lines. On the -th line, there is an integer , meaning that after the -th reset there are energy-rich islands, followed by integers , which are the indices of the energy-rich islands.
Output Format
Output lines. For each use of the machine, output the minimum total cost required to prevent the enemy from reaching any energy-rich island from island .
10
1 5 13
1 9 6
2 1 19
2 4 8
2 3 91
5 6 8
7 5 4
7 8 31
10 7 9
3
2 10 6
4 5 7 8 3
3 9 4 6
12
32
22
Hint
Constraints
- For of the testdata, , .
- For of the testdata, , , .
- For of the testdata, , .
- For of the testdata, , , , , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号