博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[图算法] 1003. Emergency (25)
阅读量:4490 次
发布时间:2019-06-08

本文共 2145 字,大约阅读时间需要 7 分钟。

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 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

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 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

 

#include 
#include
#include
#include
#include
#include
using namespace std;const int maxn=510;const int INF=1e9;int g[maxn][maxn];int n,m,st,dt;int d[maxn]={ 0};int weight[maxn];bool vis[maxn]={ false};int w[maxn];int num[maxn]={ 0};void dijkstra(int s){ fill(d,d+maxn,INF); fill(w,w+maxn,0); d[s]=0; w[s]=weight[s]; num[s]=1; for(int i=0;i
>n>>m>>st>>dt; for(int i=0;i
>weight[i]; for(int i=0;i
>id1>>id2>>cost; g[id1][id2]=cost; g[id2][id1]=cost; } dijkstra(st); cout<
<<" "<
<

 

转载于:https://www.cnblogs.com/xiongmao-cpp/p/6440026.html

你可能感兴趣的文章
lucene笔记
查看>>
tomcat无法正常shutdown
查看>>
zookeeper + dubbo 搭建
查看>>
根据前序遍历和中序遍历求出二叉树并打印
查看>>
LeetCode "Divide Two Integers"
查看>>
mcs51 串口通信 单片机发 pc收
查看>>
MySQL ACID及四种隔离级别的解释
查看>>
text-align 属性,输入框数字向右靠
查看>>
二叉搜索树(搜索二叉树)转换成一个双向链表
查看>>
Linux下的时间戳
查看>>
xpath的学习
查看>>
kvm系列之四:热添加技术
查看>>
grep命令
查看>>
火狐浏览器设置bypass
查看>>
java Object类的公共方法
查看>>
UOJ356 [JOI2017春季合宿] Port Facility 【启发式合并】【堆】【并查集】
查看>>
思百德全区播放的个人见解及B区ISO破除区码播放教程
查看>>
Delphi的命令行编译命令
查看>>
BZOJ 1901 Zju2112 Dynamic Rankings 题解
查看>>
C++虚析构函数
查看>>