poj 1797 Heavy Transportation
来源:互联网 发布:淘宝油烟净化器 编辑:程序博客网 时间:2024/04/30 08:39
最短路ing~
前三道大水题。。。
慢慢来吧。
#include<cstdio>#include<algorithm>#include<cstring>#include<iostream>using namespace std;const int inf = 0x3f3f3f3f;const int Max = 1005;int dict[Max],edge[Max][Max],n,m;bool vis[Max];int minn(int x,int y) { if(x < y) return x; else return y;}void dijkstra() { int maxx,now = 1,k; for(int s = 1;s <= n;s++) { maxx = 0; for(int i = 2;i <= n;i++) { if(!vis[i]) { if(edge[now][i] != 0 && dict[i] < edge[now][i]) dict[i] = edge[now][i]; if(maxx < dict[i]) maxx = dict[k = i]; } } vis[k] = true; if(k == n) break; now = k; } int ans = inf; for(int j = 2;j <= n;j++) if(vis[j]) ans = minn(ans,dict[j]); printf("%d\n\n",ans);}int main() { int tt; scanf("%d",&tt); for(int t = 1;t <= tt;t++) { scanf("%d%d",&n,&m); memset(edge,0,sizeof(edge)); memset(dict,0,sizeof(dict)); memset(vis,false,sizeof(vis)); vis[1] = true;dict[1] = 0; for(int i = 1;i <= m;i++) { int x,y,value; scanf("%d%d%d",&x,&y,&value); if(edge[x][y] == 0 || edge[x][y] < value) { edge[x][y] = value; edge[y][x] = value; } } printf("Scenario #%d:\n",t); dijkstra(); }}
0 0
- POJ 1797 Heavy Transportation
- POJ 1797 Heavy Transportation
- poj 1797Heavy Transportation
- poj 1797 Heavy Transportation
- POJ 1797 Heavy Transportation
- poj 1797 Heavy Transportation
- POJ 1797 Heavy Transportation
- POJ 1797 Heavy Transportation
- poj 1797 Heavy Transportation
- Poj 1797 Heavy Transportation
- poj 1797 Heavy Transportation
- poj 1797 Heavy Transportation
- POJ-1797-Heavy Transportation
- POJ 1797 Heavy Transportation
- poj 1797 Heavy Transportation
- poj 1797 Heavy Transportation
- POJ 1797 Heavy Transportation
- POJ 1797 Heavy Transportation
- 分类战车SVM (第四话:拉格朗日对偶问题)
- 如何扩展 web 服务器?----阿里巴巴2015校招研发在线
- 数的计算
- Linux framebuffer example
- PiLC - S7 PLC for Raspberry Pi
- poj 1797 Heavy Transportation
- js 中对象属性特性的描述
- Linux虚拟机的三种网络连接方式
- 有两个32bit的数A、B,使用下面方式得到32bit的数C、D。哪一种可以使用C、D得到A、B的值?----阿里巴巴2015校招研发在线
- Yii2.0 上传图片
- Python Generators(生成器)——yield关键字
- 解决Mac OS lion下(ubuntu等linux也一样)启动tomcat的Cannot find ./catalina.sh 的问题
- innerHTML innerText outerHTML outerText的区别
- LaTex