题目链接:http://poj.org/problem?id=1797

Heavy Transportation
Time Limit: 3000MS   Memory Limit: 30000K
Total Submissions: 30840   Accepted: 8191

Description

Background 
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

The first line contains the number of scenarios (city plans). For each city the number n of street crossings (1 <= n <= 1000) and number m of streets are given on the first line. The following m lines contain triples of integers specifying start and end crossing of the street and the maximum allowed weight, which is positive and not larger than 1000000. There will be at most one street between each pair of crossings.

Output

The output for every scenario begins with a line containing "Scenario #i:", where i is the number of the scenario starting at 1. Then print a single line containing the maximum allowed weight that Hugo can transport to the customer. Terminate the output for the scenario with a blank line.

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的更多相关文章

  1. poj 1797 Heavy Transportation(最大生成树)

    poj 1797 Heavy Transportation Description Background Hugo Heavy is happy. After the breakdown of the ...

  2. POJ 1797 Heavy Transportation / SCU 1819 Heavy Transportation (图论,最短路径)

    POJ 1797 Heavy Transportation / SCU 1819 Heavy Transportation (图论,最短路径) Description Background Hugo ...

  3. POJ.1797 Heavy Transportation (Dijkstra变形)

    POJ.1797 Heavy Transportation (Dijkstra变形) 题意分析 给出n个点,m条边的城市网络,其中 x y d 代表由x到y(或由y到x)的公路所能承受的最大重量为d, ...

  4. POJ 1797 Heavy Transportation SPFA变形

    原题链接:http://poj.org/problem?id=1797 Heavy Transportation Time Limit: 3000MS   Memory Limit: 30000K T ...

  5. POJ 1797 Heavy Transportation (Dijkstra变形)

    F - Heavy Transportation Time Limit:3000MS     Memory Limit:30000KB     64bit IO Format:%I64d & ...

  6. POJ 1797 ——Heavy Transportation——————【最短路、Dijkstra、最短边最大化】

    Heavy Transportation Time Limit:3000MS     Memory Limit:30000KB     64bit IO Format:%I64d & %I64 ...

  7. POJ 1797 Heavy Transportation (最大生成树)

    题目链接:POJ 1797 Description Background Hugo Heavy is happy. After the breakdown of the Cargolifter pro ...

  8. POJ 1797 Heavy Transportation (Dijkstra)

    题目链接:POJ 1797 Description Background Hugo Heavy is happy. After the breakdown of the Cargolifter pro ...

  9. POJ 1797 Heavy Transportation(最大生成树/最短路变形)

    传送门 Heavy Transportation Time Limit: 3000MS   Memory Limit: 30000K Total Submissions: 31882   Accept ...

随机推荐

  1. Portlet和servlet的区别

    相同之处 l 都是java技术开发的web组件 l 都是由特定的容器在管理 l 都可以动态产生各种内容 l 生命周期都是由容器管理 l 和客户端的交互通过request/response机制 不同之处 ...

  2. ASIHTTPRequest 在release(打包)模式下数据获取或post失败问题

    ASIHTTPRequest 在relase模式下失效 表现为,调用网络请求后没有任何反应 原因之一: ARC模式下,在ASIHTTPRequest 前面会加上__weak来解决循环应用,这个__we ...

  3. SVN服务器配置实战

    [需求] 为公司多个部门建立的SVN仓库compay 公司部门和人员构成 A部门 (zhangsan,lisi,wanger,mazi) B部门(jia,yi,bing,ding) C部门(chun, ...

  4. ios 8+ (xcode 6.0 +)应用程序Ad Hoc 发布前多设备测试流程详解

    我们开发的程序在经过simulator以及自己的iOS设备测试后,也基本完成应用程序了,这时候我们就可以把它发布出去了更更多的人去测试,我们可以在iOS平台使用ad hoc实现. 你在苹果购买的开发者 ...

  5. 如何由Height Map生成Normal Map

    转自:http://www.cnblogs.com/cxrs/archive/2009/11/01/1594155.html Nvidia和ATI都有相应的工具把Heightmap转成NormalMa ...

  6. 功率与dbm的对照表

     功率与dbm的对照表 分类: 嵌入式 功率与dbm的对照表 对于无线工程师来说更常用分贝dBm这个单位,dBm单位表示相对于1毫瓦的分贝数,dBm和W之间的关系是:dBm=10*lg(mW)1w的功 ...

  7. 产生冠军 map 的 应用 .

    开始 比赛  ,  每一次的 比赛 都会有人失败 , 如果产生英雄的话  , 那就是产生 唯一一个 没有被打败的人  , 就是英雄, . #include<stdio.h> #includ ...

  8. python3爬虫初探(三)之正则表达式

    前面已经写了如何获取网页源码,那么接下来就是该解析网页并提取需要的数据了.这里简单写一下正则表达的用法. 首先,找个要抓取图片的网站,获取源码. import requests import re # ...

  9. ViewBag、ViewData和TempData的使用和区别

    在MVC3开始,视图数据可以通过ViewBag属性访问,在MVC2中则是使用ViewData. MVC3中保留了ViewData的使用. ViewBag 是动态类型(dynamic),ViewData ...

  10. Linux下查看每个目录所占用空间大小的命令

    cd到上级目录,然后输入一条命令即可查询每个子目录所占用的空间大小 du -h --max-depth=1 可以更改--max-depth参数的值,该参数表示查询子目录的层级,当前为1层