Thursday, September 8, 2016

Light OJ 1040 - Donation



Problem link - 1040 - Donation

Its a very basic mst problem.

let us try to analyze some test case

2
27 26
1 52





here 
we can see if we keep only the cable with 1 meter then all rooms are connected and we can donate all other cables so the answer becomes (27+26+52+1) - 1 = 105

stdout

Case 1: 105





4
0 1 0 0
1 0 0 0
0 0 0 1
0 0 1 0






here
All rooms are not connected  by a single path so the output will be - 1










No comments:

Post a Comment

Football Player Transfer Prediction

Football Player Transfer Prediction Using Different Classifiers Project Report :  Football Player Transfer Prediction Report ...