HDU 1599 find the mincost route
来源:互联网 发布:编辑歌曲的软件 编辑:程序博客网 时间:2024/05/21 04:21
转载请注明出处:http://blog.csdn.net/a1dark
分析:这是一道floyd求最小环的模板题、
#include<string.h>#include<stdio.h>#include<iostream>using namespace std;const int INF=10000000;const int maxn=102;int map[maxn][maxn];int map1[maxn][maxn];int n,m,minc;void floyd(){ minc=INF; for(int k=1;k<=n;k++) { for(int i=1;i<=k;i++) for(int j=i+1;j<=k;j++) minc=min(minc,map1[i][j]+map[k][i]+map[k][j]); for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) map1[i][j]=min(map1[i][j],map1[i][k]+map1[k][j]); }}int main(){ while(scanf("%d%d",&n,&m)!=EOF) { for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) { map[i][j]=INF; map1[i][j]=INF; } int s,e,w; for(int i=0;i<m;i++) { scanf("%d%d%d",&s,&e,&w); w=min(map[s][e],w); map[s][e]=w; map[e][s]=w; map1[s][e]=w; map1[e][s]=w; } floyd(); if(minc<INF) printf("%d\n",minc); else printf("It's impossible.\n"); } return 0;}
- hdu 1599 find the mincost route
- HDU 1599 find the mincost route
- hdu 1599 find the mincost route
- hdu 1599 find the mincost route
- HDU 1599 find the mincost route
- HDU 1599 find the mincost route
- hdu 1599 find the mincost route
- HDU 1599 find the mincost route
- hdu 1599 find the mincost route
- hdu 1599 find the mincost route
- HDU 1599 find the mincost route
- hdu 1599 find the mincost route
- HDU 1599 find the mincost route
- 【HDU 1599 find the mincost route】
- HDU 1599 find the mincost route
- 【HDU 1599 find the mincost route 】
- HDU 1599 find the mincost route
- HDU-1599-find the mincost route
- 订单签名错误,请检查partner对应的密钥是否正确
- hdu1712 ACboy needs your help
- vs2012 快速注释/取消注释
- hdu4698 Counting
- Java多线程(七)、Volatile 关键字
- HDU 1599 find the mincost route
- 一个异常的例子
- 黑马程序员-Java面向对象-day07
- 微生物
- windows文件比较命令
- ubuntu下安装配置SSH
- 章小结
- 打印100以内的素数
- Window.open() 全攻略