#P1195. 口袋的天空
口袋的天空
Description
You are given the number of clouds , and then relations indicating which clouds can be connected.
Now Xiaoshan wants to connect all clouds into exactly cotton candies (connected components). Each cotton candy must use at least one cloud. He wants to know how to connect them so that the total cost is minimized.
Input Format
The first line contains three integers .
Each of the next lines contains three integers , meaning cloud and cloud can be connected at a cost of .
Output Format
Output one line containing a single integer, the minimum total cost.
If it is impossible to obtain exactly cotton candies, output No Answer.
3 1 2
1 2 1
1
Hint
Constraints:
- For of the testdata, , .
- For of the testdata, , , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号