博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PAT_A1003#Emergency
阅读量:5891 次
发布时间:2019-06-19

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

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 N1), 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 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

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 #include
12 #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

 

转载于:https://www.cnblogs.com/blue-lin/p/11051952.html

你可能感兴趣的文章
c-4
查看>>
Hadoop生态圈-Kafka的新API实现生产者-消费者
查看>>
23种设计模式-观察者模式
查看>>
【音乐分享】天后
查看>>
如何在手机上禁止浏览器的网页滚动
查看>>
li里包含左侧图片右侧文字自适应-------解决文字环绕图片的方法
查看>>
css3 的box-sizing属性理解
查看>>
PIN Block Formats – The Basics
查看>>
逆向工程,生成pojo、xml、mapper
查看>>
[Web 前端] qs.parse()、qs.stringify()使用方法
查看>>
[Web 前端] CSS 盒子模型,绝对定位和相对定位
查看>>
10.19 科大讯飞笔试小记
查看>>
黑客帝国、乱雨纷飞效果
查看>>
css水平垂直居中
查看>>
Charles设置抓取https请求
查看>>
Python Django 之 静态文件存放设置
查看>>
Android Zxing框架扫描解决扫描框大小,图片压缩问题
查看>>
swift学习之常量和变量
查看>>
面试中变相考算法复杂度
查看>>
Python_Day7_面向对象学习
查看>>