[poj2387] Til the Cows Come Home
来源:互联网 发布:淘宝店能贷款吗 编辑:程序博客网 时间:2024/05/18 02:40
题目链接
思路:dijkstra模板
#include <iostream>#include <cstdio>#include <cstring>using namespace std;#define INF 1000000000int m,n,x,y,z;int w[2005][2005];int d[2005],vis[2005];void dijkstra(){ for(int i=1;i<=n;i++) d[i]=INF; d[1]=0; for(int i=1;i<=n;i++) { int x,m=INF; for(int j=1;j<=n;j++) { if(m>d[j]&&!vis[j]){ m=d[j]; x=j; } } vis[x]=1; for(int j=1;j<=n;j++) d[j]=min(d[j],d[x]+w[x][j]); }}int main(){ scanf("%d%d",&m,&n); memset(w,63,sizeof(w)); memset(vis,0,sizeof(vis)); for(int i=1;i<=m;i++){ scanf("%d%d%d",&x,&y,&z); if(z<w[x][y]) w[x][y]=w[y][x]=z; } dijkstra(); cout<<d[n]<<endl; return 0;}
0 0
- poj2387- Til the Cows Come Home
- poj2387- Til the Cows Come Home
- POJ2387 Til the Cows Come Home
- POJ2387 Til the Cows Come Home【Dijkstra】
- POJ2387----Til the Cows Come Home(dijkstra)
- POJ2387---Til the Cows Come Home
- POJ2387 Til the Cows Come Home
- [poj2387] Til the Cows Come Home
- poj2387 Til the Cows Come Home
- poj2387 Til the Cows Come Home
- poj2387 Til the Cows Come Home
- POJ2387 Til the Cows Come Home
- POJ2387 Til the Cows Come Home
- Poj2387- Til the Cows Come Home
- POJ2387 Til the Cows Come Home
- POJ2387 Til the Cows Come Home
- POJ2387-Til the Cows Come Home
- POJ2387 Til the Cows Come Home
- 理解Twisted的Deferred机制(一)
- Fragment的用法
- linux 查看磁盘空间大小
- 阿里云+wordpress搭建个人博客网站【小白专用的图文教程】
- std::function与std::bind 函数指针
- [poj2387] Til the Cows Come Home
- VS2013打开项目提示"Asp.net4.5未在web服务器上注册 "
- 确定学习方向规划自己学习计划
- Java程序员应该了解的10个面向对象设计原则
- js笔记--函数表达式
- [李景山php]每天laravel-20160903|Dispatcher-3
- 地图坐标拾取系统
- jquery判断元素是否隐藏的多种方法
- Android-onInterceptTouchEvent()和onTouchEvent()总结