#P11260. [GDKOI2023 普及组] Himitsu

[GDKOI2023 普及组] Himitsu

Background

Some unnecessary images are omitted.

Problem Description

Lily cannot forget the night in her childhood when she ran away together with Nana before they parted. In order to explore the truth of the universe, they walked along the railway tracks and saw huge fish surging from the horizon, floating in the night sky. From then on, Lily never stopped studying the secrets of the universe.

Secrets always exist, one or two of them. With the floating fish as a typical example, there were nn major events about the universe in Lily’s world. Intrigue, perfect crimes, the universe’s dark matter—these events seem unrelated to each other. But Lily reads books about the universe every day, and from the last page of the books she summarizes mm pieces of interpretation. Each piece of interpretation can connect two of the events.

Adults hope Lily will reveal some of the interpretations that have already been obtained, so that all events can be linked together. But Lily knows that if these interpretations are exposed, probably about half the classmates will start planning to run away. Revealing secrets always costs Lily something. Suppose the cost to reveal each interpretation can be quantified: the cost to reveal the ii-th interpretation is an integer wiw_i. The total cost Lily needs to pay is the sum of the costs of all interpretations she reveals, under the condition that the revealed interpretations can connect all events together.

Lily also knows that among them there are kk key interpretations about the truth of the world, carrying the secret of 77 billion people. How many of these interpretations are revealed will directly determine the possibility of humanity continuing. People argue and say that perhaps only these two children can save the world; the justice of 77 billion people deprives the freedom of 22 people, and they eagerly want to know Lily’s answer.

You want to know, for every integer ii from 00 to kk, under the condition that Lily reveals some interpretations that can connect all events, and among them there are exactly ii key interpretations, what is the minimum total cost Lily has to pay.

“I don’t understand,” Lily cried like this. She will hold on to the secret, and wait according to the promise for the moment she meets Nana again.

Input Format

The first line contains three integers n,m,kn, m, k, representing the number of events, the total number of interpretations, and the number of key interpretations.

Then follow mm lines, each containing three integers u,v,wu, v, w, representing an interpretation that can connect event uu and event vv, but revealing this interpretation costs ww.

Among these mm lines, the first kk lines represent the key interpretations known by Lily.

Output Format

Output k+1k + 1 lines, each containing one integer ansans.

In particular, the integer ansians_i on the ii-th line indicates the minimum total cost when revealing exactly i1i - 1 key interpretations.

The testdata guarantees that even if none of the key interpretations are revealed, the remaining interpretations can still connect all events together.

5 8 2
3 4 6
2 1 6
1 4 8
1 2 10
2 3 4
3 4 5
4 5 4
2 4 6
21
19
20

Hint

Constraints

1u,vn,1w1091 \le u, v \le n, 1 \le w \le 10^9.

For 30%30\% of the testdata, 1n1001 \le n \le 100, 1m4001 \le m \le 400, 1k51 \le k \le 5.

For another 30%30\% of the testdata, 1n100001 \le n \le 10000, 1m10000001 \le m \le 1000000, 1k201 \le k \le 20.

For the remaining 40%40\% of the testdata, 1n100001 \le n \le 10000, 1m10000001 \le m \le 1000000, 1k501 \le k \le 50.

When the contest problem was activated, there were already 88 billion people on the small planet.

Translated by ChatGPT 5