UVa 11463 - Commandos
来源:互联网 发布:剑雨江湖进阶数据仙器 编辑:程序博客网 时间:2024/05/20 17:07
题目:有一个敢死队,要摧毁一群建筑,他们从一个特定的建筑出发,最后到一个特定的建筑集合;
现在给你各个建筑之间的连接路线,在建筑中穿梭需要1个单位时间,问集合的最早时间。
分析:图论,最短路径。直接计算起点s和终点e到那个其他所有点的最短路径;
取min(dist(s,k)+ dist(k,e))即可(0≤k<n)。
说明:第650题目╮(╯▽╰)╭。
#include <algorithm>#include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>#include <cmath>using namespace std;int path[101][101];int main(){int T,n,m,u,v,b,e;while (~scanf("%d",&T))for (int t = 1; t <= T; ++ t) {scanf("%d%d",&n,&m);for (int i = 0; i < n; ++ i) {for (int j = 0; j < n; ++ j)path[i][j] = 101;path[i][i] = 0;}for (int i = 0; i < m; ++ i) {scanf("%d%d",&u,&v);path[u][v] = path[v][u] = 1;}//floydfor (int k = 0; k < n; ++ k)for (int i = 0; i < n; ++ i)for (int j = 0; j < n; ++ j)if (path[i][j] > path[i][k]+path[k][j])path[i][j] = path[i][k]+path[k][j];scanf("%d%d",&b,&e);int max = 0;for (int k = 0; k < n; ++ k)if (max < path[b][k]+path[k][e])max = path[b][k]+path[k][e];printf("Case %d: %d\n",t,max);} return 0;}
0 0
- UVa 11463 - Commandos
- uva 11463 Commandos
- Commandos (UVA-11463)
- Commandos
- commandos 系列
- Gym Commandos
- FOJ 1635 Commandos
- FZU 1635 Commandos
- FOJ 1635 Commandos
- FOJ(1635)Commandos
- LightOJ 1174--Commandos (BFS)
- LightOJ - 1174 Commandos
- LightOJ - 1174 Commandos(floyd)
- lightOJ 1174 - Commandos
- Commandos--关于foyld经典算法
- FOJ--1635--Commandos--解题报告
- LIGHTOJ 1174 – COMMANDOS 【FLOYD】
- LightOJ 1174 Commandos(FLoyd)
- Qt 出现error: expected constructor, destructor, or type conversion before ‘typedef’
- SAT阅读真题考什么?
- CocoaPods安装和使用教程
- 尽快报告坏消息
- Lombok — Java代码自动生成 开发利器 Eclipse for Mac
- UVa 11463 - Commandos
- SQL Script for read information from a csv file in FTP Server
- JAXB注解使用
- 中文分词的应用 新浪和庖丁两种方式对比
- HDU 3277 Marriage Match III(并查集+二分答案+最大流SAP)拆点,经典
- 如何做淘宝客推广淘宝客教程视频
- java操作redis
- 50条大牛C++编程开发学习建议
- RMAN-06026,RMAN-06100