HDU 1599 find the mincost route 无向图最小环
来源:互联网 发布:机动车扣分查询软件 编辑:程序博客网 时间:2024/05/18 03:38
题目来源:HDU 1599 find the mincost route
题意:求最小的3点组成的环
思路:floyd
http://blog.sina.com.cn/s/blog_476a25110100mag6.html
http://www.cppblog.com/mythit/archive/2009/04/21/80579.aspx
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int maxn = 110; int a[maxn][maxn];int d[maxn][maxn];int n, m, ans;void floyd(){ for(int k = 1; k <= n; k++) { for(int i = 1; i < k; i++) { for(int j = i+1; j < k; j++) { ans = min(ans, d[i][j]+a[i][k]+a[k][j]); } } for(int i = 1; i <= n; i++) { for(int j = 1; j <= n; j++) { d[i][j] = min(d[i][j], d[i][k]+d[k][j]); } } }}int main(){while(scanf("%d %d", &n, &m) != EOF){for(int i = 0; i <= n; i++){for(int j = 0; j <= n; j++){if(i == j)a[i][j] = d[i][j] = 0;elsea[i][j] = d[i][j] = 99999999;}}while(m--){int u, v, w;scanf("%d %d %d", &u, &v, &w); if(a[u][v] > w){a[u][v] = w;a[v][u] = w;d[u][v] = w;d[v][u] = w;}}ans = 99999999;floyd(); if(ans == 99999999)puts("It's impossible.");else printf("%d\n", ans);}return 0;}
0 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 (无向图floyd最小环详解)
- hdu 1599 find the mincost route(无向图最小环,floyd)
- HDU 1599 find the mincost route 无向图最小环
- hdu 1599 find the mincost route(floyd求无向图的最小环)
- HDU 1599 find the mincost route 无向图最小环
- hdu 1599find the mincost route(Floyd算法,最小环无向图)
- HDU-1599 find the mincost route (无向图最小环[Floyd])
- HDU:1599 find the mincost route(floyd+无向图最小环)
- HDU 1599 find the mincost route(无向图最小环)
- HDU 1599 find the mincost route(Floyd无向图最小环)
- HDU 1599 find the mincost route(无向图最小环)
- hdu 1599 find the mincost route(找无向图最小环)(floyd求最小环)
- HDU1599 find the mincost route 无向图最小环
- hdu1599 find the mincost route(floyd求无向图最小环)
- 无向图最小环 hdu1599 (find the mincost route)
- 认识Javascript中的navigator对象以及检测浏览器类型和版本,获取浏览器版本号,检测客户端操作系统
- Flume-ng分布式部署和配置
- 冯东阳:吐胆汁分享原创文章写作经验
- CentOS(Linux) VPS 防暴力登录账户和密码
- Jquery 怎么只给点击的元素加个class(互斥)
- HDU 1599 find the mincost route 无向图最小环
- 错误 18456 ___ODBC 创建新数据源
- nyoj-984-最长回文
- javascript:void(0)链接
- [Google Guava] 2.1-不可变集合
- hdu1080 - Human Gene Functions 最长公共子序列推广
- MySQL数据类型中DECIMAL的作用和用法
- HBase技术介绍
- 西安80后大学老师离奇失踪 疑房贷等压力大