It was a minimum spanning tree problem. For Wakanda to be connected it needs (number of cities that have people on it) - 1 edges . Start adding edges in the MST where both city u and v have people on it . If the number of edges ( cnt ) that are added in the MST are less than (cities-1) then we have to add (cities-1-cnt) more edges in the MST for Wakanda to be connected and each of those edges will have length d.

Statistics

88% Solution Ratio
prodip_bsmrstuEarliest, Apr '19
MR.Jukerburg11Fastest, 0.0s
mdshadeshLightest, 5.4 kB
SpellMasterShortest, 721B
Toph uses cookies. By continuing you agree to our Cookie Policy.