(关系幂运算->n长度的最短路)河南省第十届ACM省赛题目:问题 I: Transmit information
来源:互联网 发布:知乎 修改一句话介绍 编辑:程序博客网 时间:2024/06/07 01:33
问题 I: Transmit information
提交: 2 解决: 2
[提交][状态][讨论版]
题目描述
The Chinese people threw themselves into an all-out war of resistance against Japanese aggression in 1937. The first line of resistance against aggression was formed by spies and underground workers.
They lurked in every place of the city.
There's a piece of information that needs to be passed on to them. Now there is a traffic map, each road connects two different intersectionsXiand Yi, each of which is the termination for at least two road. The length of each road is known LENi, no two intersections are directly connected by two different roads.
N spies lurk at every intersection , some intersections mignt have more than one spy. For security, they must position themselves properly ,each spy cannot accept information from localintersection , can only be transferred from elsewhere and end up at the finishing pace.
At first, the information is in the hands of a spy atS intersection. AfterN spies transmission, and finally arrived atE intersection .
Write a program to find the shortest path that connects the starting intersection(S) and the ending intersection(E) ang transmission exactly N spies.
输入
The first line of the input contains one integers T, which is the nember of test cases (1<=T<=5). Each test case specifies:
* Line 1: Four space-separated integers: N M S E
* Lines 2..M+1: Line i+1 describes road i with three space-separated integers: LENi Xi Yi
( 2<=N<=300,000 2<=M<=100, 1<= LENi, Xi, Yi ,S, E <=1000 i=1,…,m)
输出
For each test case generate a single line containing a single integer that is the shortest path from intersection S to intersection E thattransmits exactly N spies.
样例输入
12 6 6 411 4 64 4 88 4 96 6 82 6 93 8 9
样例输出
10
【体会】:这题在赛时连题意都没读懂。。。。。。。。赛后百度到一篇题解,原来是求S到E点的长度为N的最短路。
竟然回到了离散知识。
对于邻接矩阵,进行关系的幂运算,就可以得到长度为指数的邻接矩阵。
比如邻接矩阵A,进行关系的幂运算,得到A的n次方,那得到的矩阵中的A[i][j]表示i到j的长度为n的路的权值
(我这里说的长度是走过的边的数目)
(关系的幂运算:利用关系的传递性,进行运算,跟矩阵乘法不一样。跟弗洛伊德算法相似)
转载一篇题解吧:http://blog.csdn.net/wyxeainn/article/details/72603049
- (关系幂运算->n长度的最短路)河南省第十届ACM省赛题目:问题 I: Transmit information
- 河南省第十届ACM省赛题目:问题 I: Transmit information
- 河南第十届ACM省赛-I-Transmit information
- 河南省第十届ACM省赛题目:问题 C: 最小秘钥
- 河南省第十届ACM省赛题目:问题 D: 年终奖金
- 河南省第十届ACM省赛题目:问题 B: 情报传递
- 河南省第十届ACM省赛题目:问题 A: 谍报分析
- 河南省第十届ACM省赛题目:问题 F: Binary to Prime
- 河南省第十届ACM省赛题目:问题 G: Plumbing the depth of lake
- 河南省第十届ACM省赛题目:问题 H: Intelligent Parking Building
- 第十届河南省ACM省赛总结
- nyoj 1237(第八届河南省acm省赛题目)
- 第十届河南省acm省赛参赛总结
- 整理第十届河南省ACM省赛正解
- 河南省第十届ACM题解 C 最小秘钥
- 第八届河南省赛 最少换乘(最短路)
- 河南省第十届ACM赛题
- 河南省第七届ACM题目
- hdu 3172 Virtual Friends(加权并查集)
- map、list查询速度
- Maven详解(六)------ 生命周期
- 数值计算和SVM讲解(下)
- apache tomat安装
- (关系幂运算->n长度的最短路)河南省第十届ACM省赛题目:问题 I: Transmit information
- HDU 5545 The Battle of Guandu(最短路)
- WebService的基本介绍和调用实例
- Mysql删除表提示Cannot truncate a table referenced in a foreign key constraint解决办法
- A Concise and Provably Informative Multi-Scale Signature Based on Heat Diffusion
- 继承中的final/super关键字、Object类
- Spring MVC 属性文件读取注入到静态字段
- 【九度OJ】1193:矩阵转置
- 20179.4,考虑置信区间数据清洗和结果均值检测