HDU 1599 find the mincost route(Floyd判最小环)
来源:互联网 发布:人工智能培训机构 编辑:程序博客网 时间:2024/05/01 00:50
#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>#include <queue>#include <set>#define inf 10000000#define ll __int64using namespace std;int Map[600][600],ed[600][600],n,m,cnt;void Floyd(){ int i,j,k; for(k=1;k<=n;k++) { for(i=1;i<k;i++) { for(j=1;j<i;j++) { cnt=min(cnt,ed[i][j]+Map[i][k]+Map[k][j]); } } for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { ed[i][j]=min(ed[i][j],ed[i][k]+ed[k][j]); } } } if(cnt>=inf) { printf("It's impossible.\n"); } else printf("%d\n",cnt);}int main(){ int i,j,k; while(~scanf("%d%d",&n,&m)) { cnt=inf; for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { if(i!=j) { ed[i][j]=Map[i][j]=inf; } else { ed[i][j]=Map[i][j]=0; } } } int a,b,c; for(i=0;i<m;i++) { scanf("%d%d%d",&a,&b,&c); if(Map[a][b]>c) { ed[a][b]=ed[b][a]=Map[a][b]=Map[b][a]=c; } } Floyd(); } return 0;}
0 0
- HDU 1599 find the mincost route(Floyd判最小环)
- HDU 1599 find the mincost route Floyd求最小环
- hdu 1599 find the mincost route floyd求最小环
- HDU 1599 find the mincost route (Floyd 最小环)
- HDU 1599 find the mincost route(Floyd最小环)
- HDU - 1599 find the mincost route(Floyd求最小环)
- hdu 1599 find the mincost route(floyd 最小环)
- hdu 1599 find the mincost route【floyd求最小环】
- hdu 1599 find the mincost route 求最小环floyd
- hdoj 1599 find the mincost route 【floyd + 最小环】
- HDOJ--1599--find the mincost route(floyd+最小环)
- HDU 1599 find the mincost route (无向图floyd最小环详解)
- hdu 1599 find the mincost route(无向图最小环,floyd)
- hdu 1599 find the mincost route(floyd求无向图的最小环)
- HDU 1599 find the mincost route (Floyd求最小环) >>
- hdu 1599find the mincost route(Floyd算法,最小环无向图)
- hdu 1599 find the mincost route (最小环与floyd算法)
- HDU-1599 find the mincost route (无向图最小环[Floyd])
- [实践]Spring MVC——消息转换器的编码(防止中文乱码)
- 如何正确的完全卸载MySQL
- delphi中文件拖入功能的实现
- Chapter 3-01
- Java JVM(十二):指令重排序
- HDU 1599 find the mincost route(Floyd判最小环)
- Visual Studio2015错误C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_
- 分布式系统的Raft算法
- 微软涉足千元机市场 发布883元手机Lumia 550
- 结构体字节对齐
- 【威尔逊定理】HDOJ YAPTCHA 2973
- [每日一答] [20151007] RStudio中,出现中文乱码问题的解决方案
- PHP MYSQL命令
- HTC悄然发布One E9s 售人民币2063元