The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 2 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
A country has V cities. Certain pairs of cities are connected by undirected transport roads between them. There are E such transport roads. There exists a sequence of roads connecting every city in the the country to every other city.
Among the V cities, K of the cities are good cities.
Â
Initially all the cities are free. The country is ruled by two kings. The first king wants no friendship with the second king, while the other king wants friendship with the first king. They now play a game of conquering cities.
Â
The first king selects a good city, then the second king selects a good city and so on; until all the good cities are over.
Suppose at the end some good cities belong to kingdom A and others to B. Distance value between the two kingdoms is defined as the sum of shortest distances between each pair of good cities X and Y such that X belongs to A and Y belongs to B.
Â
The first king wants to maximize the distance value and other king wants to minimize this. Assuming that both play optimally, find out the distance value after the end of the game.
Â
Â
First line contain three space separated integers denoting V, E, and K respectively.
Â
For next E lines, each line contain 3 space separated integers, u v w, denoting that there is an edge from u to v of length w.
Â
The following line contains K space separated integers denoting the indices of the good cities. Indices are given by using 1 based indexation.
Â
Â
A single integer, the maximum possible distance that can be achieved if both kings play optimally.
Â
Â
Â
Input: 4 5 3 1 2 5 1 3 2 1 4 3 2 4 2 3 4 2 1 2 4 Output: 7
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll