BLINNET - Bytelandian Blingors Network
We have discovered the fastest communication medium Bytelandian scientists announced, and they called it blingors. The blingors are incomparably better than other media known before. Many companies in Byteland started to build blingors networks, so the information society in the kingdom of Bytes is fact! The priority is to build the core of the blingors network, joinig main cities in the country. Assume there is some number of cities that will be connected at the beginning. The cost of building blingors connection between two cities depends on many elements, but it has been successfully estimated. Your task is to design the blingors network connections between some cities in this way that between any pair of cities is a communication route. The cost of this network should be as small as possible.
- The name of the city is a string of at most 10 letters from a,...,z.
- The cost of the connection between two cities is a positive integer.
- The sum of all connections is not greater than 232-1.
- The number of cities is not greater than 10 000.
s [number of test cases <= 10] n [number of cities <= 10 000] NAME [city name] p [number of neigbouring cities to the city NAME] neigh cost [neigh - the unique number of city from the main list cost - the cost of building the blingors connection from NAME to neigh] [empty line between test cases]
[separate lines] cost [the minimum cost of building the blingors network]
Input: 2 4 gdansk 2 2 1 3 3 bydgoszcz 3 1 1 3 1 4 4 torun 3 1 3 2 1 4 1 warszawa 2 2 4 3 1 3 ixowo 2 2 1 3 3 iyekowo 2 1 1 3 7 zetowo 2 1 3 2 7 Output: 3 4Warning: large Input/Output data, be careful with certain languages
classical MST ^_-
vuhuuu! first mst and dusted in one go.. *_*
my 69th :P
Ac in one go, classical MST.
City names are completely unnecessary here. AC by kruskal's alg
Do we even need the city names for the solution?
easy with mst!!
my 50th :D
classical MST :p