博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
POJ 2263 Heavy Cargo(Floyd + map)
阅读量:5320 次
发布时间:2019-06-14

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

Heavy Cargo
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 3768   Accepted: 2013

Description

Big Johnsson Trucks Inc. is a company specialized in manufacturing big trucks. Their latest model, the Godzilla V12, is so big that the amount of cargo you can transport with it is never limited by the truck itself. It is only limited by the weight restrictions that apply for the roads along the path you want to drive.
Given start and destination city, your job is to determine the maximum load of the Godzilla V12 so that there still exists a path between the two specified cities.

Input

The input will contain one or more test cases. The first line of each test case will contain two integers: the number of cities n (2<=n<=200) and the number of road segments r (1<=r<=19900) making up the street network.
Then r lines will follow, each one describing one road segment by naming the two cities connected by the segment and giving the weight limit for trucks that use this segment. Names are not longer than 30 characters and do not contain white-space characters. Weight limits are integers in the range 0 - 10000. Roads can always be travelled in both directions.
The last line of the test case contains two city names: start and destination.
Input will be terminated by two values of 0 for n and r.

Output

For each test case, print three lines:
  • a line saying "Scenario #x" where x is the number of the test case
  • a line saying "y tons" where y is the maximum possible load
  • a blank line

Sample Input

4 3Karlsruhe Stuttgart 100Stuttgart Ulm 80Ulm Muenchen 120Karlsruhe Muenchen5 5Karlsruhe Stuttgart 100Stuttgart Ulm 80Ulm Muenchen 120Karlsruhe Hamburg 220Hamburg Muenchen 170Muenchen Karlsruhe0 0

Sample Output

Scenario #180 tons Scenario #2170 tons

Source

题意:求各城市每条给定起点和终点间通路的最小负载,并据此求出所有最小负载中的最大值.
思路:题目给的是城市名用map.
收获:map用法 + Floyd
#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;const int INF=0x3f3f3f3f;const double eps=1e-10;const double PI=acos(-1.0);#define maxn 500map
a;char s1[32];char s2[32];int c[maxn][maxn];int v[maxn][maxn];int pre[maxn][maxn];int main(){ int n, m, w; int cas = 0; while(~scanf("%d%d",&n,&m)&&(n+m)) { int cnt = 0; memset(c, 0, sizeof c); for(int i = 0; i < m; i++) { scanf("%s%s%d", s1, s2, &w); if(!a.count(s1)) a[s1] = cnt++; if(!a.count(s2)) a[s2] = cnt++; c[a[s1]][a[s2]] = c[a[s2]][a[s1]] = w; }// map
::iterator it;// for(it=a.begin();it!=a.end();++it)// cout<<"key: "<
first <<" value: "<
second<

 

转载于:https://www.cnblogs.com/ZP-Better/p/4714803.html

你可能感兴趣的文章
apache自带压力测试工具ab的使用及解析
查看>>
jenkins搭建
查看>>
加固linux
查看>>
IPSP问题
查看>>
10.17动手动脑
查看>>
WPF中Image显示本地图片
查看>>
php仿阿里巴巴,php实现的仿阿里巴巴实现同类产品翻页
查看>>
面对问题,如何去分析?(日报问题)
查看>>
nodejs vs python
查看>>
poj-1410 Intersection
查看>>
Java多线程基础(一)
查看>>
SQL Server中利用正则表达式替换字符串
查看>>
初始面向对象
查看>>
leetcode Letter Combinations of a Phone Number
查看>>
Unity 5.4 测试版本新特性---因吹丝停
查看>>
7.5 文件操作
查看>>
MyEclipse中将普通Java项目convert(转化)为Maven项目
查看>>
node js 安装.node-gyp/8.9.4 权限 无法访问
查看>>
windows基本命令
查看>>
VMware中CentOS设置静态IP
查看>>