#P5540. [BalkanOI 2011] timeismoney
[BalkanOI 2011] timeismoney
Description
Given an undirected graph with vertices and edges, the -th edge has two weights and .
Find a spanning tree of this graph such that
$$\left(\sum_{e\in T}a_e\right)\times\left(\sum_{e\in T}b_e\right)$$is minimized.
Input Format
The first line contains two positive integers .
The next lines each contain integers , meaning that the -th edge connects and , with weights and .
The vertices are numbered from to .
Output Format
Suppose the spanning tree you found is . Output one line with two integers, which are and .
If there are multiple solutions, output the one with the smallest .
4 5
0 1 1 2
0 2 2 3
0 3 1 5
1 3 3 4
2 3 1 3
3 10
Hint
For of the testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号