Source:
Description:
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 Specification:
Each input file contains one test case. For each test case, the first line contains 4 positive integers: N (≤) - 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 Mlines follow, each describes a road with three integers c1, c2 and L, which are the pair of cities connected by a road and the length of that road, respectively. It is guaranteed that there exists at least one path from C1 to C2.
Output Specification:
For each test case, print in one line two numbers: the number of different shortest paths between C1and C2, and the maximum amount of rescue teams you can possibly gather. All the numbers in a line must be separated by exactly one space, and there is no extra space allowed at the end of a line.
Sample Input:
5 6 0 21 2 1 5 30 1 10 2 20 3 11 2 12 4 13 4 1
Sample Output:
2 4
Keys:
Code:
1 /* 2 Data: 2019-06-19 15:37:05 3 Problem: PAT_A1003#Emergency 4 AC: 16:05 5 6 题目大意: 7 求权值最大的最短路径 8 输出: 9 最短路径数,最大带权路径长度10 */11 #include12 #include 13 using namespace std;14 const int M=550,INF=1e9;15 int grap[M][M],vis[M],d[M],w[M];16 int n,m,st,dt,c[M],t[M];17 18 void Dijskra(int s)19 {20 fill(vis,vis+M,0);21 fill(d,d+M,INF);22 fill(c,c+M,0);23 fill(t,t+M,0);24 d[s]=0;25 t[s]=1;26 c[s]=w[s];27 for(int i=0; i c[v])54 c[v]=c[u]+w[v];55 }56 }57 }58 }59 }60 61 int main()62 {63 #ifdef ONLINE_JUDGE64 #else65 freopen("Test.txt", "r", stdin);66 #endif // ONLINE_JUDGE67 68 fill(grap[0],grap[0]+M*M,INF);69 scanf("%d%d%d%d", &n,&m,&st,&dt);70 for(int i=0; i