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 ...
随机推荐
- subString用法,字符串保持一定位数,不足补0
Substrinig(a,b): 从下标a开始截取,共截取b位 实现:一串数字,中间两位数字+2,生成新的一串数字 "; , number.Length - );//前8位 );//后6位 ...
- 戴文的Linux内核专题:05配置内核(1)
转自Linux中国 现在我们已经了解了内核,现在我们可以进入主要工作:配置并编译内核代码.配置内核代码并不会花费太长时间.配置工具会询问许多问题并且允许开发者配置内核的每个方面.如果你有不确定的问题或 ...
- 用时间生成用户Id
用用户注册时的时间,作为新用户的Uid: /** * 生成用户id,用时间生成 * * @return */ public static String date2UserId() { SimpleDa ...
- mac终端下运行shell脚本
最近公司要弄关于IOS下自动化打包的东西,研究了用命令行的形式来代替手工的方式来处理.即: 用xcodebuild 和xcrun 语法来进行脚本实现. 但由于语法的结构够了,另一个问题产生了, ...
- apache http client vs urlconnection
Google has deprecated HttpClient Choose an HTTP Client Most network-connected Android apps use HTTP ...
- LeetCode----Copy List with Random Pointer 深度拷贝,浅度拷贝,Lazy拷贝解析
题目:A linked list is given such that each node contains an additional random pointer which could poin ...
- 如何去除内联元素(inline-block元素)之间的间距(转载)
如何去除内联元素(inline-block元素)之间的间距 前几天写一个专题页 div{width:900px;}div a{ display:inline-block; width:300px; ...
- iOS 微信 音频 视频自动播放
iOS 微信 音频 视频自动播放 http://www.w3ctech.com/topic/1165
- Java 集合深入理解(8):AbstractSequentialList
点击查看 Java 集合框架深入理解 系列, - ( ゜- ゜)つロ 乾杯~ 今天有点无聊,来学学 AbstractSequentialList 解解闷 吧! AbstractSequentialLi ...
- CODEVS3123 a*b problem plus (FFT)
type xh=record x,y:double; end; arr=..] of xh; var n,m:longint; s1,s2:ansistring; a,b,g,w:arr; ch:ch ...