1072. Gas Station (30)
时间限制
200 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue
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 the houses are in its service range.
Now given the map of the city and several candidate locations for the gas station, you are supposed to give the best recommendation. If there are more than one solution, output the one with the smallest average distance to all the houses. If such a solution is still not unique, output the one with the smallest index number.
Input Specification:
Each input file contains one test case. For each case, the first line contains 4 positive integers: N (<= 103), the total number of houses; M (<= 10), the total number of the candidate locations for the gas stations; K (<= 104), the number of roads connecting the houses and the gas stations; and DS, the maximum service range of the gas station. It is hence assumed that all the houses are numbered from 1 to N, and all the candidate locations are numbered from G1 to GM.
Then K lines follow, each describes a road in the format
P1 P2 Dist
where P1 and P2 are the two ends of a road which can be either house numbers or gas station numbers, and Dist is the integer length of the road.
Output Specification:
For each test case, print in the first line the index number of the best location. In the next line, print the minimum and the average distances between the solution and all the houses. The numbers in a line must be separated by a space and be accurate up to 1 decimal place. If the solution does not exist, simply output “No Solution”.
Sample Input 1:
4 3 11 5 1 2 2 1 4 2 1 G1 4 1 G2 3 2 3 2 2 G2 1 3 4 2 3 G3 2 4 G1 3 G2 G1 1 G3 G2 2
Sample Output 1:
G1 2.0 3.3
Sample Input 2:
2 1 2 10 1 G1 9 2 G1 20
Sample Output 2:
No Solution
N个城市,M个站点, K条路,天然气站点能辐射范围最远DS;
(K行)城市或站点 城市或站点 距离;
……
PS其中城市编号1~N;站点G~GM;
目标求某一站点符合要求(越前面的条件越重要) 必须:所有的城市都在等于辐射范围或以内;
多个必须,那么附加:在这些站点中 取(每个城市到站点的最小距离)最长的那个站点;
多个必须并最小距离相等,那么附加:在这些站点中,取到各个城市【总距离最短】的站点;
符合必须,并最小距离相等并总距离相等,取编号小的站点;
简单的说就是,在能够提供服务的前提下(职能问题)
站点到城市的最小距离越大越好,(环境或危险性问题)
站点到各个城市的距离总和越少越好(浪费问题)
编号选择小的(答案唯一问题)
熬夜找了好久的错误,发现错误认为char c[3]可以符合,但是G10,100也是存在的
评测结果
时间 | 结果 | 得分 | 题目 | 语言 | 用时(ms) | 内存(kB) | 用户 |
8月15日 01:51 | 答案正确 | 30 | 1072 | 13 | 692 |
测试点
测试点 | 结果 | 用时(ms) | 内存(kB) | 得分/满分 |
0 | 答案正确 | 1 | 180 | 16/16 |
1 | 答案正确 | 1 | 308 | 2/2 |
2 | 答案正确 | 1 | 308 | 4/4 |
3 | 答案正确 | 1 | 308 | 4/4 |
4 | 答案正确 | 13 | 692 | 4/4 |