You would like to provide citizens of a newly constructed neighborhood with cable television. As a computer scientist, you know this calls for... wires!
Surveyors have done their work and have given you the cost of connecting pairs of locations. However, they have also warned you that certain links might be dangerous - there is a risk of interference from power lines and such. Find the minimum cost to connect all the houses, minimizing the cost but above all minimizing the number of dangerous links used.
Input Specification
, the number of locations.
, the number of possible links.
lines, each with four integers , , , . Each line signifies a possible (bidirectional) link between locations and , with cost . will be if the link is dangerous, and otherwise.
Output Specification
Two integers.
Output a) the minimum number of dangerous links required and b) the total minimum cost.
Sample Input
4 4
1 2 2 0
2 3 1 1
3 1 1 0
3 4 1 1
Sample Output
1 4
Take , , and .
The use of one dangerous cable is inevitable, but we can avoid the use of the other.
Comments
What are the limits on cost?
there is no limit (i think, correct me if im wrong) it's just the min cost when you also minimize the number of dangerous edges/links
I'm correcting you because you're wrong :) (jk)