欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

PAT1003Emergency (25)

程序员文章站 2022-05-15 20:43:55
...

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

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 (

Output

For each test case, print in one line two numbers: the number of different shortest paths between C1 and 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 Input5 6 0 2
1 2 1 5 3
0 1 1
0 2 2
0 3 1
1 2 1
2 4 1
3 4 1

Sample Output2 4

const int maxn = 510;
int ans, n, m, s, t, v[maxn], dis[maxn], mapPA[maxn][maxn], x, y, z, vis[maxn];
long long cnt[maxn];
//n-城市数量,m-道路数量,s-起点,t-终点
void dfs(int x, int y, int z){
    ans = max(ans, z);
    if (x == y || dis[x] == -1)return;
    for (int i = 0; i if