1. State Planning A planned state consists of cities connected by bidirectional roads of different types. For example, one road may be an expressway and another a boulevard. Each road can be described by three integers that represent the two connected cities and the road type. To reduce maintenance, some roads may be demolished. All others will be upgraded. If each city is to remain connected to all currently connected cities by the same type of road, determine the minimum number of roads of each type that will be upgraded. Example numCities=4 numRoads 5 numTypes = 2 fromCity=[3,0, 0, 2, 11 toCity=[2.3, 2, 1, 31 roadType=[1.0.0.1.11
Answers
Answered by
0
Answer:
Ans
Explanation:
There are n cities and there are roads in between some of the cities. Somehow all the roads are damaged simultaneously. We have to repair the roads to connect the cities again. There is a fixed cost to repair a particular road. Find out the minimum cost to connect all the cities by repairing roads. Input is in matrix(city) form, if city[i][j] = 0 then there is not any road between city i and city j, if city[i][j] = a > 0 then the cost to rebuild the path between city i and city j is a. Print out the minimum cost to connect all the cities.
It is sure that all the cities were connected before the roads were damaged.
Similar questions
English,
15 days ago
Social Sciences,
1 month ago
Physics,
9 months ago
Social Sciences,
9 months ago