Computer Science, asked by latestvideobackup, 1 month ago

4. There are N people in city, who wants to visit Kingdom of Dreams. The road of reaching of Kingdom is not so safe. Therefore, they go to kingdom only in a security vehicle, which can accommodate at the most two people (There is only one security vehicle available in the town as it is quite costly and unique). People started to hire this vehicle to reach safely by driving it by themselves. Every part of journey from town to kingdom or from kingdom to town has some cost associated withrit which is given by an array A[ ] elements. Array A[ ] has N elements, where A(i) represents the cost ith person has to pay if they travel alone in the vehicle. If two people travel in vehicle, the cost of travel will be the maximum of cost of two people. Calculate the minimum total cost so that all N people can reach Kingdom safely.​

Answers

Answered by anjanfayaz
0

Answer:

Which was the capital of the chalullyas? (a) Madurai (b) Kanauj (c) Varanasi (d) Aihole

Explanation:

  • Which was the capital of the chalullyas? (a) Madurai (b) Kanauj (c) Varanasi (d) Aihole
Answered by SharadSangha
0

Input:

  • The first line contains A – the number of test cases. First line of each test case contains two integers M – the number of cities and N –the number of existing roads.
  • Next N lines contain city id pairs x and y (1 - based indexed) for existing roads between cities.
  • Next line contains a single integer L – the number of additional roads that can be built. L lines follow.
  • Each of these L lines consists of three space separated integers – x, y and Z denoting a road between cities x and y with cost Z.

1 <= A <= 10

1 <= M <= 10000

1 <= L+N <= 1000000

1 <= Z <= 1000000

1 <= x,y <= N

Output:

We need to print the minimum cost it takes to connect cities in a way such that there exists a path between every two cities.

For first test case:

  • There are already roads between cities 1 to 4 and 1 to 3. So, cities 1, 3 and 4 are connected to each other.
  • Now we need to connect city 2 with any one of them to make a connected Kingdom.

Hence, the minimum cost of the road that connects to city 2 is 15.

#SPJ2

Similar questions