MST - Minimum Spanning Tree
Find the minimum spanning tree of the graph.
On the first line there will be two integers N - the number of nodes and M - the number of edges. (1 <= N <= 10000), (1 <= M <= 100000)
M lines follow with three integers i j k on each line representing an edge between node i and j with weight k. The IDs of the nodes are between 1 and n inclusive. The weight of each edge will be <= 1000000.
Single number representing the total weight of the minimum spanning tree on this graph. There will be only one possible MST.
Input: 4 5 1 2 10 2 3 15 1 3 5 4 2 2 4 3 40 Output: 17
|Added by:||Nikola P Borisov|
|Cluster:||Cube (Intel Pentium G860 3GHz)|
|Languages:||All except: ERL JS NODEJS PERL 6 SCM chicken VB.net|
i am getting a compilation error although my code runs fine in ideone!..plz help
@paci :fair enough!!!
Antony Skarlatos (Hepic):
Use long long for distance(or weight),to take 100%.
long long gives 100.
Thank You Aman
isnt this problem same as http://www.spoj.com/problems/CSTREET/
my solution got accepted , but result is 0 , wht it means ?
Lại Mạnh Tuấn:
@ Aman Gupta: Thanks for the suggestion