POJ 1797 Heavy Transportation
题目链接:http://poj.org/problem?id=1797
| Time Limit: 3000MS | Memory Limit: 30000K | |
| Total Submissions: 30840 | Accepted: 8191 |
Description
Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there really is a way from the place his customer has build his giant steel crane to the place where it is needed on which all streets can carry the weight.
Fortunately he already has a plan of the city with all streets and bridges and all the allowed weights.Unfortunately he has no idea how to find the the maximum weight capacity in order to tell his customer how heavy the crane may become. But you surely know.
Problem
You are given the plan of the city, described by the streets (with weight limits) between the crossings, which are numbered from 1 to n. Your task is to find the maximum weight that can be transported from crossing 1 (Hugo's place) to crossing n (the customer's place). You may assume that there is at least one path. All streets can be travelled in both directions.
Input
Output
Sample Input
1
3 3
1 2 3
1 3 4
2 3 5
Sample Output
Scenario #1:
4 题目大意:样例个数T,给定N个点,及M条边的最大负载,求顶点1到N的最大流。
// 1.给定一个双向可达的有向图,求出1->n之间的所有可达路径,每条路径中的最小边的最大值。
AC代码:
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int visit[];
int dis[];
int p[][];
int n;
int dijkstra()
{
int i,j,pos,minn;
for (i = ; i <= n; i ++)
{
dis[i] = p[][i];
visit[i] = ;
}
dis[] = ;
visit[] = ; for (i = ; i <= n; i ++)
{
minn = ;
for (j = ; j <= n; j ++)
{
if (!visit[j] && dis[j] > minn)
{
minn = dis[j];
pos = j;
}
}
visit[pos] = ;
for (j = ; j <= n; j ++)
{
if(!visit[j] && dis[j] < min(dis[pos],p[pos][j]))
dis[j] = min(dis[pos],p[pos][j]);
}
}
return dis[n];
}
int main()
{
int t,m,x,y,z,i,j,f = ;
scanf("%d",&t);
while (t --)
{
scanf("%d%d",&n,&m);
for (i = ; i <= n; i ++)
for (j = ; j <= n; j ++)
p[i][j] = ;
for (i = ; i < m; i ++)
{
scanf("%d%d%d",&x,&y,&z);
p[x][y] = p[y][x] = z;
}
printf("Scenario #%d:\n",f ++);
printf("%d\n\n",dijkstra()); //注意格式
}
}
POJ 1797 Heavy Transportation的更多相关文章
- poj 1797 Heavy Transportation(最大生成树)
poj 1797 Heavy Transportation Description Background Hugo Heavy is happy. After the breakdown of the ...
- POJ 1797 Heavy Transportation / SCU 1819 Heavy Transportation (图论,最短路径)
POJ 1797 Heavy Transportation / SCU 1819 Heavy Transportation (图论,最短路径) Description Background Hugo ...
- POJ.1797 Heavy Transportation (Dijkstra变形)
POJ.1797 Heavy Transportation (Dijkstra变形) 题意分析 给出n个点,m条边的城市网络,其中 x y d 代表由x到y(或由y到x)的公路所能承受的最大重量为d, ...
- POJ 1797 Heavy Transportation SPFA变形
原题链接:http://poj.org/problem?id=1797 Heavy Transportation Time Limit: 3000MS Memory Limit: 30000K T ...
- POJ 1797 Heavy Transportation (Dijkstra变形)
F - Heavy Transportation Time Limit:3000MS Memory Limit:30000KB 64bit IO Format:%I64d & ...
- POJ 1797 ——Heavy Transportation——————【最短路、Dijkstra、最短边最大化】
Heavy Transportation Time Limit:3000MS Memory Limit:30000KB 64bit IO Format:%I64d & %I64 ...
- POJ 1797 Heavy Transportation (最大生成树)
题目链接:POJ 1797 Description Background Hugo Heavy is happy. After the breakdown of the Cargolifter pro ...
- POJ 1797 Heavy Transportation (Dijkstra)
题目链接:POJ 1797 Description Background Hugo Heavy is happy. After the breakdown of the Cargolifter pro ...
- POJ 1797 Heavy Transportation(最大生成树/最短路变形)
传送门 Heavy Transportation Time Limit: 3000MS Memory Limit: 30000K Total Submissions: 31882 Accept ...
随机推荐
- Zabbix页面遇到历史记录的乱码需要修改数据库
Zabbix页面遇到历史记录的乱码需要修改数据库: 解决办法: 1.将 zabbix 数据库中的表备份: 2.手动删除 zabbix 数据库: 3.重新创建 zabbix 库时手动指定字符集为 utf ...
- JavaScript 自定义事件
//自定义事件 function Event() { var handles = []; //绑定事件 this.addHandle=function(fn) { handles.push(fn); ...
- bzoj 1036 Tree Count
题目大意:给出一棵树,每个点有一个权值,要求三种操作:1.修改某个点的权值,2.询问x到y路径上各点的权值最大值,3.询问x到y路径上各点的权值之和. #include <cstdio> ...
- CSS基本特性
1.块状元素有大小:行内元素没有,除非脱离文档流(如float.absolute) 2.内部元素决定大小 不管外面元素是哪种类别(块状或行内),里面元素都可以撑大外面 3.外部元素决定位置
- How To Create A Struts 2 Web Application
以简单登录为例 1.创建一个Dynamic Web projec项目记得勾选Generate web.xml deployment dsecriptor 2.引入Struts 2工程所需运行库文件 解 ...
- SQL Server 按某一字段分组 取 最大 (小)值所在行的数据
SQL Server 按某一字段分组 取 最大 (小)值所在行的数据 -- 按某一字段分组 取 最大 (小)值所在行的数据 -- (爱新觉罗.毓华(十八年风雨,守得冰山雪莲花开) 2007-10-23 ...
- hadoop环境搭建遇到问题集锦
1 在hadoop的bin目录下, 运行hadoop version命令,提示“hadoop:没有此命令” 解决办法: ./hadoop version或者$HADOOP_HOME/bin放在PAT ...
- 解决:Android4.3锁屏界面Emergency calls only - China Unicom与EMERGENCY CALL语义重复
从图片中我们可以看到,这里在语义上有一定的重复,当然这是谷歌的原始设计.这个问题在博客上进行共享从表面上来看着实没有什么太大的意义,不过由于Android4.3在锁屏功能上比起老版本做了很大的改动,而 ...
- BZOJ 2982 combination
lucas定理裸题. #include<iostream> #include<cstdio> #include<cstring> #include<algor ...
- HDOJ-三部曲一(搜索、数学)-1005-Dungeon Master
Dungeon Master Time Limit : 2000/1000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other) Tot ...