博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj1734 Sightseeing trip(Floyd求无向图最小环)
阅读量:7215 次
发布时间:2019-06-29

本文共 1024 字,大约阅读时间需要 3 分钟。

1 #include 
2 #include
3 #include
4 #include
5 #include
6 using namespace std; 7 8 typedef long long ll; 9 const int maxn = 100 + 5;10 const int inf = 0x3f3f3f3f;11 int n, m, ans;12 int mp[maxn][maxn], dis[maxn][maxn], pos[maxn][maxn];13 vector
path;    //记录路径14 inline void getpath( int x, int y ){15 if( pos[x][y]==0 ) return;16 getpath( x, pos[x][y] );17 path.push_back(pos[x][y]);18 getpath( pos[x][y], y );19 }20 21 inline void floyd(){22 ans = inf;23 for( int k=1; k<=n; k++ ){24 for( int i=1; i
dis[i][k]+dis[k][j] ){  //此处要按dis[i][k]+dis[k][j]更新最短距离 而不是mp[i][k]+mp[k][j]37 dis[i][j] = dis[i][k]+dis[k][j];38 pos[i][j] = k;39 }40 }41 }42 43 int main(){44 scanf("%d%d", &n, &m);45 memset( mp, inf, sizeof(mp) );46 memset( pos, 0, sizeof(pos) );47 for( int i=0; i<=n; i++ ) mp[i][i] = 0;48 for( int i=0; i

 

转载于:https://www.cnblogs.com/WAautomaton/p/10845771.html

你可能感兴趣的文章
C++ const 理解
查看>>
Linux进程管理 (7)实时调度
查看>>
基于鲁棒图进行概念架构设计
查看>>
Permission denied: exec of '/var/www/html/bugzilla/index.cgi' failed
查看>>
LESS CSS 框架简介与使用
查看>>
2014.09线上课堂报名帖:敏捷个人手机应用使用
查看>>
C# 重启exe
查看>>
Web 服务器 之 简易WWW服务器的架设
查看>>
一种电子病历系统软件框架思想
查看>>
轻松破解NewzCrawler时间限制
查看>>
gDebugger 3.1.1 原版+破解
查看>>
C++ 对象的内存布局(上)
查看>>
在Outlook中用VBA导出HTML格式邮件
查看>>
搭建一个免费的,无限流量的Blog----github Pages和Jekyll入门
查看>>
PHP——通过下拉列表选择时间(转)
查看>>
由1433端口入侵,浅谈sqlserver安全 (转)
查看>>
2个YUV视频拼接技术
查看>>
spring data实现自定义的repository实现类,实现跟jpa联通
查看>>
“惊群”,看看nginx是怎么解决它的
查看>>
Theano3.3-练习之逻辑回归
查看>>