博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Heavy Transportation
阅读量:2038 次
发布时间:2019-04-28

本文共 3219 字,大约阅读时间需要 10 分钟。

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

13 31 2 31 3 42 3 5

Sample Output

Scenario #1:4
#include 
#include
#include
#include
#include
#include
using namespace std;#define MAXV 1010int map[MAXV][MAXV],n,m;int vis[MAXV],d[MAXV];int spfa(){ queue
q; int v; for(int i=1;i<=n;i++){ vis[i]=0; d[i]=0; } q.push(1); vis[1]=1; while(!q.empty()){ v=q.front();q.pop(); vis[v]=0; for(int i=1;i<=n;i++){ if(v==1 && map[v][i]){ d[i]=map[v][i]; q.push(i); vis[i]=1; continue; } if(d[i]

 

/*4128K 375MSDijkstra邻接矩阵*/#include 
using namespace std;#define MAXV 1010#define min(a,b) (a
f){                f=d[j];                v=j;            }        vis[v]=1;         for(j=1;j<=n;j++)            if(!vis[j] && d[j]
#include
using namespace std;#define MAXV 1010#define min(a,b) (a
q;    int i,j,v;    int vis[MAXV],d[MAXV];    for(i=1;i<=n;i++){        vis[i]=0;        d[i]=0;    }    q.push(1);    vis[1]=1;    while(!q.empty()){        v=q.front();q.pop();        vis[v]=0;         for(i=1;i<=n;i++){            if(v==1 && map[v][i]){                d[i]=map[v][i];                q.push(i);                vis[i]=1;                continue;            }            if(d[i]
using namespace std;#define MAXV 1010#define min(a,b) (a
using namespace std;#define MAXV 1010#define MAXE 1000010#define min(a,b) (a
using namespace std;#define MAXV 1010#define MAXE 1000010#define min(a,b) (a
using namespace std;#define MAXV 1010#define min(a,b) (a

 

转载地址:http://sewof.baihongyu.com/

你可能感兴趣的文章
对Rabbitmq rpc返回队列的一点理解
查看>>
HttpServletRequest和ServletRequest的区别
查看>>
初学Shiro
查看>>
java8之Lambda表达式 1:简介
查看>>
java8之Lambda表达式 2:内建函数式接口
查看>>
java8之Lambda表达式 3:数据流
查看>>
java8之Lambda表达式 4:MapReduce开发案例
查看>>
java性能优化之一 VO的使用
查看>>
mysql删除数据不能带表名
查看>>
揭开Spring事务处理
查看>>
DUBBO配置规则详解
查看>>
防止用户多次登录的两种做法
查看>>
java性能优化之二 循环里面不使用hibernate创建对象
查看>>
java性能优化之三 优雅平滑的结束quarts 任务
查看>>
JAVA随机数之多种方法从给定范围内随机N个不重复数
查看>>
java使double保留两位小数的多方法 java保留两位小数
查看>>
Spring事务中涉及到多线程的处理方式
查看>>
实现页面登录后仍然跳回当前页面
查看>>
Jmeter 测试java并发
查看>>
简单java程序测试并发数
查看>>