当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

4222:Graph Theory?

题目描述
In mathematics and computer science, graph theory is the study of graphs, mathematical structures used to model pairwise relations between objects from a certain collection. A graph is a collection of vertices and a collection of edges that connect pairs of vertices.
Simple word, we have an undirected graph with weight on its edge, and we want to choose a key point on this graph, be careful, the key point can be not only on a vertex, but also on an edge.
To make the problem more close to reality and easy to understand, imagine it’s a country where everybody wants to go aboard, say TC for example, and the key point is the only exit of this country to the outside colorful world. The N vertices can be treated as cities, M edges as roads. And if the key point is chosen, everyone in every city will choose a shortest path to the key point, and leave this country as if one second more will erase the purity and dignity.
But one last thing, visa. To simplify the problem, we already change the ID order and only the last K vertices have a visa office. One may choose any of those cities to get a visa. Of course, they will choose a visa-city to make the total length as short as possible.
And now, we come back to handle the original problem, where should the key vertex be? There are also two viewpoints for judging where the most perfect place is. We use Di to record the minimum cost for people in city i to get a visa and reach the key point, and Pi people in this city. The first opinion claims the Max(Di * Pi) to be as small as possible, while the second claims the Sum(Di * Pi) to be as small as possible. Your task is to solve both of these requests.
For each request, report the minimum value it claims, and then, report the place it can choose to achieve that value. If more than one such place, report INFINITE instead (you may assume the people in TC only know 0 and 1, other numbers are just infinite for them).
If you need to report a chosen place for key point, report the first edge id (1-based) the point appears, and then the distance between the point and the first vertex. For example, if there is only an edge <1, 2>, and the key point lies in vertex 1, report (1, 0.000).
输入解释
The first line contains a single integer T, indicating the number of test cases.
Each test case includes three integers N, M, K. Then a line with N integers Pi follows. Then M lines following, each line contains three integers Ai, Bi, Ci, describing an undirected road. You can assume there is as least one path between any city pair.

Technical Specification
1. 1 <= T <= 64
2. 1 <= K < N <= 32
3. 0 <= Pi <= 1024
4. N - 1 <= M <= 512
5. 1 <= Ci <= 1024
6. 1 <= Ai, Bi <= N, Ai != Bi, no edge pair appears more than once.
输出解释
For each test case, output the case number in the first line. Then two lines, the first line describe the max request, and the second describe the sum request, as the format in the description.
Separate them by exactly one space, print “INFINITE” without quote if needed, and round all the floating numbers to three fractional digits. Refer to the sample output for more details.
Even more than one such place, you should report the minimum value it claims first.
输入样例
2
3 3 1
1 2 3
1 2 1
2 3 2
1 3 3
4 4 2
3 2 1 1
1 2 2
2 3 2
3 4 2
4 1 2
输出样例
Case 1:
4.000 2 2.000
7.000 2 2.000
Case 2:
7.200 3 1.600
16.000 3 2.000
来自杭电HDUOJ的附加信息
Author iSea@WHU
Recommend lcy

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-4222

最后修改于 2020-10-25T23:11:26+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
16000/8000MS(Java/Others) 65536/65536K(Java/Others)