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.

 
  题目就是求最大路。。。
 
代码如下:
#include<iostream>
#include<cstring>
#include<queue>
#include<vector>
#include<cstdio> #define min(a,b) (a<b ? a:b) using namespace std; const int INF=10e8;
const int MaxN=; struct Node
{
int v,val; Node(int _v=,int _val=):v(_v),val(_val) {}
bool operator < (const Node &a) const
{
return val<a.val;
}
}; struct Edge
{
int v,cost; Edge(int _v=,int _cost=):v(_v),cost(_cost) {}
}; vector <Edge> E[MaxN]; void Dijkstra(int lowcost[],int n,int start)
{
priority_queue <Node> que;
Node qtemp;
int len;
int u,v,cost; for(int i=;i<=n;++i)
{
lowcost[i]=;
}
lowcost[start]=INF; que.push(Node(start,INF)); while(!que.empty())
{
qtemp=que.top();
que.pop(); u=qtemp.v; len=E[u].size(); for(int i=;i<len;++i)
{
v=E[u][i].v;
cost=E[u][i].cost; if(min(cost,lowcost[u])>lowcost[v])
{
lowcost[v]=min(cost,lowcost[u]);
que.push(Node(v,lowcost[v]));
}
}
}
} inline void addEdge(int u,int v,int c)
{
E[u].push_back(Edge(v,c));
} int ans[MaxN]; int main()
{
// ios::sync_with_stdio(false); int N,M;
int a,b,c;
int T; scanf("%d",&T); for(int cas=;cas<=T;++cas)
{
scanf("%d %d",&N,&M); for(int i=;i<=N;++i)
E[i].clear(); for(int i=;i<=M;++i)
{
scanf("%d %d %d",&a,&b,&c); addEdge(a,b,c);
addEdge(b,a,c);
} Dijkstra(ans,N,); printf("Scenario #%d:\n",cas);
printf("%d\n\n",ans[N]);
} return ;
}

(简单) POJ 1797 Heavy Transportation,Dijkstra。的更多相关文章

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

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

  2. POJ 1797 Heavy Transportation (Dijkstra)

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

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

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

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

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

  5. POJ 1797 Heavy Transportation

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

  6. POJ 1797 Heavy Transportation SPFA变形

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

  7. POJ 1797 Heavy Transportation (Dijkstra变形)

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

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

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

  9. POJ 1797 Heavy Transportation (dijkstra 最小边最大)

    Heavy Transportation 题目链接: http://acm.hust.edu.cn/vjudge/contest/66569#problem/A Description Backgro ...

随机推荐

  1. 查找mysql数据库中所有包含特定名字的字段所在的表

    整个数据库查找 placement 字段: select * from INFORMATION_SCHEMA.columns where COLUMN_NAME Like '%placement%'; ...

  2. new thoughts over function pointers

    Previous works do not relate to function pointers, but reading some documents reading and learning S ...

  3. [转]Android 导入v7包常见错误,以及项目引用v7包错误解决

    android下v4    v7   v21等包是android系统的扩展支持包,就想windows的系统补丁一个道理. android的扩展包主要是用来兼容低版本的,比如android3.0以后出现 ...

  4. 《割绳子》《蜡笔物理学》《Contre Jour》《顽皮鳄鱼爱洗澡》等游戏用Box2D引擎实现物理部分的方法(转)

    从最热门游戏排行榜和flash游戏网站上,你能看到什么?许多2D游戏都有非常出色的物理学和美术设计.现在我们要学习那些游戏使用了什么物理学以及如何用Box2D制作它们. 除了知道是“什么”,更重要的是 ...

  5. publish over ssh

    http://stackoverflow.com/questions/22158092/jenkins-transferring-0-files-using-publish-over-ssh-plug ...

  6. ActiveMQ的配置与使用

    1.什么是ActiveMQ MQ全称为Message Queue, 消息队列(MQ)是一种应用程序对应用程序的通信方法.应用程序通过写和检索出入列队的针对应用程序的数据(消息)来通信,而无需专用连接来 ...

  7. Oracle sql优化之分析函数优化标量子查询

    待优化语句如下 select a.code as code, a.m_code as m_code,a.stktype as f_stype,a.e_year as e_year, b.sname a ...

  8. Datatable.select() 方法的使用

    文章为转载 ,原文地址 DataTable是我们在进行开发时经常用到的一个类,并且经常需要对DataTable中的数据进行筛选等操作,下面就介绍一下Datatable中经常用到的一个方法--Selec ...

  9. hdu_5085_Counting problem(莫队分块思想)

    题目连接:hdu_5085_Counting problem 题意:给你一个计算公式,然后给你一个区间,问这个区间内满足条件的数有多少个 题解:由于这个公式比较特殊,具有可加性,我们考虑讲一个数分为两 ...

  10. Nginx反向代理使用【转载】

    最近工作中经常使用nginx,为了能够更好的使用nginx,我搜罗了很多nginx相关的技术文章来读,所以才有了下面以下内容.在此,为文中引用到和参考到的文章提供者表示感谢.如文中相关内容有错误,也欢 ...