39 Exercise 8.5 Local Minimum Cost Problem of Smooth Project (Programming Question) [PTA Zhejiang University Edition "Data Structure (2nd Edition)" Question Collection]
1. Original title link
Exercise 8.5 Local Minimum Cost Problem of Smooth Access Project (pintia.cn)
2.Title description
After a survey of urban traffic conditions in a certain region, statistical data on existing express roads between towns were obtained, and the goal of the "smooth project" was put forward: to enable rapid transportation between any two towns in the entire region (but there may not necessarily be direct connections). Expressways are connected, as long as each other is reachable indirectly through the expressway). Now we have the urban road statistics table, which lists the cost of building an expressway between any two towns and the status of whether the road has been repaired. Now please write a program to calculate the minimum cost for smooth traffic in the entire region.
Input format:
The first line of input gives the number of villages N N N (