As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered (零散的)cities connected by some roads. Amount of rescue teams in each city and the length of each road between any pair of cities are marked on the map. When there is an emergency call to you from some other city, your job is to lead your men to the place as quickly as possible, and at the mean time, call up as many hands on the way as possible.
Input
Each input file contains one test case. For each test case, the first line contains 4 positive integers: N (<= 500) – the number of cities (and the cities are numbered from 0 to N-1), M – the number of roads, C1 and C2 – the cities that you are currently in and that you must save, respectively. The next line contains N integers, where the i-th integer is the number of rescue teams in the i-th city. Then M lines follow, each describes a road with three integers c1, c2 and L, which are the pair of

本文介绍了如何使用Dijkstra算法解决紧急救援团队从城市C1出发前往城市C2的最短路径问题,同时求解路径中所能集结的最大救援队伍总数。给出的样例展示了算法的应用,并提到了在实现过程中需要注意的细节,例如避免将等于号`=`误用为等于比较操作符`==`。
最低0.47元/天 解锁文章
989

被折叠的 条评论
为什么被折叠?



