sort ordering structure

sort(q,q+n,cmp);

bool cmp (node a node b);

Target provincial government "Smooth Traffic Project" is to make between any two villages in the province can achieve road traffic (but not necessarily directly connected to the road, as long as indirectly through the road up to). After investigation and assessment, statistics obtained a list of possible construction of several roads highway costs. Now you write a program to calculate the lowest cost needed to clear the province.

Input test input contains several test cases. The first row of each road test strip evaluation given number N, the number of villages M (<100); N subsequent
cost of correspondence between the village road rows each given a pair of positive integers, respectively, two villages the number and cost of road between these two villages (and a positive integer). For simplicity, the village numbered from 1 to M. When N is 0, all the input end, an output not corresponding results.

To sort the minimum storage structure will change the value of disjoint-set.

Guess you like

Origin www.cnblogs.com/hahaee/p/11946424.html
Recommended