题目描述
A gas station has to be built at such a location that the minimum distance between the station andanyofthe residential housing is as far away as possible. However it must guarantee that all the houses are in its service range.
Now given the map ofthe city and several candidate locations forthe gas station, you are supposed to give the best recommendation. If there are more than one solution, output theonewiththe smallest average distance to all the houses. If such a solution is still not unique, output theonewiththe smallest index number.
输入描述:
Each input filecontainsone test case. For eachcase, thefirstlinecontains4 positive integers: N (<= 103), the total numberof houses; M (<= 10), the total numberofthe candidate locations forthe gas stations; K (<= 104), thenumberof roads connecting the houses andthe gas stations; and DS, the maximum service range ofthe gas station. It is hence assumed that all the houses are numbered from1to N, and all the candidate locations are numbered from G1 to GM.
Then K lines follow, each describes a road intheformat
P1 P2 Dist
where P1 and P2 are thetwoendsofa road which can be either house numbers or gas station numbers, and Dist is theintegerlengthofthe road.
输出描述:
For each test case, print inthefirstlinethe index numberofthe best location. In the next line, print the minimum andtheaverage distances between the solution and all the houses. The numbers inaline must be separated byaspaceand be accurate up to1 decimal place. If the solution does not exist, simply output “No Solution”.
输入例子:
431151221421 G1 41 G2 32322 G2 13423 G3 24 G1 3
G2 G1 1
G3 G2 2
输出例子:
G1
2.03.3
题目题目描述A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as possible. However it must guarantee that all