#P2798. 爆弹虐场
爆弹虐场
Description
On a certain day, Kiana met a boy who dominates the Explosive Mayhem Arena.
Because Kiana has studied OI for a few more years, she can barely explain to this boy some problems she is good at. Specifically, Kiana first poured unrelated knowledge points into him, and then used her [Data Deletion] technique to forcibly connect these knowledge points.
Since the boy is very strong, for each link Kiana plans to construct, he can figure it out by himself, but it will take more time. Specifically, Kiana has links. Each link can connect two unrelated knowledge points. If Kiana directly explains the -th link, it takes time; if the boy figures it out himself, it takes time.
To be lazy, Kiana only needs the links she explains or the boy figures out to make all knowledge points directly or indirectly connected. But to ensure teaching quality, Kiana thinks at least links should be figured out by the boy himself. Since Kiana’s patience is limited, she wants the longest time among all constructed links, regardless of who does them, to be as small as possible.
Now Kiana wants to know, under these conditions, what is the minimal possible value of the maximum time among the constructed links. Since she cannot compute it, she asks you to tell her.
Input Format
The input contains lines.
The first line contains three positive integers , , and , representing the number of knowledge points, the number of links Kiana wants the boy to figure out himself, and the total number of links, respectively.
Then lines follow. Each line contains four positive integers , , , and , meaning a link can be constructed between knowledge points and . If the boy figures out this link himself, it takes time; if Kiana explains it directly, it takes time.
Output Format
The output contains one line.
Print a single positive integer, the minimal possible value of the maximum time among all constructed links.
4 2 5
1 2 6 5
1 3 3 1
2 3 9 4
2 4 6 1
3 4 4 2
4
Hint
For of the testdata, , .
For of the testdata, , .
For of the testdata, , .
.
The testdata guarantees that a feasible solution exists.
Translated by ChatGPT 5
京公网安备 11011102002149号