题目链接

floyd找最小环

很好理解

 #include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define rre(i,r,l) for(int i=(r);i>=(l);i--)
#define re(i,l,r) for(int i=(l);i<=(r);i++)
#define Clear(a,b) memset(a,b,sizeof(a))
#define inout(x) printf("%d",(x))
#define douin(x) scanf("%lf",&x)
#define strin(x) scanf("%s",(x))
#define LLin(x) scanf("%lld",&x)
#define op operator
#define CSC main
typedef unsigned long long ULL;
typedef const int cint;
typedef long long LL;
using namespace std;
cint inf=;
void inin(int &ret)
{
ret=;int f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=;ch=getchar();}
while(ch>=''&&ch<='')ret*=,ret+=ch-'',ch=getchar();
ret=f?-ret:ret;
}
int n,m,t,dis[][],mp[][];
int floyd()
{
int ret=inf;
re(k,,n)
{
re(i,,n)if(i!=k)
re(j,,n)if(j!=k&&j!=i)
if(dis[i][j]<inf&&mp[i][k]!=inf&&mp[k][j]!=inf)
ret=min(ret,mp[i][k]+mp[k][j]+dis[i][j]);
re(i,,n)
re(j,,n)
dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
}
return ret;
}
int main()
{
while(scanf("%d%d",&n,&m)!=EOF)
{
re(i,,n)re(j,,m)dis[i][j]=mp[i][j]=inf;
re(i,,m)
{
int q,w,e;inin(q),inin(w),inin(e);
dis[q][w]=dis[w][q]=mp[q][w]=mp[w][q]=min(dis[q][w],e);
}
int ans=floyd();
if(ans==inf)printf("It's impossible.\n");
else printf("%d\n",ans);
}
return ;
}

hdu1599 find the mincost route的更多相关文章

  1. hdu1599 find the mincost route floyd求出最小权值的环

    find the mincost route Time Limit: 1000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/O ...

  2. hdoj 1599 find the mincost route【floyd+最小环】

    find the mincost route Time Limit: 1000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/O ...

  3. find the mincost route(最小环,最短路,floyd)

    find the mincost route Time Limit: 1000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/O ...

  4. [hdu P1599] find the mincost route

    [hdu P1599] find the mincost route 杭州有N个景区,景区之间有一些双向的路来连接,现在8600想找一条旅游路线,这个路线从A点出发并且最后回到A点,假设经过的路线为V ...

  5. HDU 1599 find the mincost route(floyd求最小环 无向图)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1599 find the mincost route Time Limit: 1000/2000 MS ...

  6. hdu 1599 find the mincost route (最小环与floyd算法)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1599 find the mincost route Time Limit: 1000/2000 MS ...

  7. hdu 1599 find the mincost route(无向图的最小环)

    find the mincost route Time Limit: 1000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/O ...

  8. hdu 1599 find the mincost route floyd求无向图最小环

    find the mincost route Time Limit: 1000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/O ...

  9. HD1599 find the mincost route(floyd + 最小环)

    题目链接 题意:求最小环 第一反应时floyd判断,但是涉及到最少3个点,然后就不会了,又想的是 双联通分量,这个不知道为什么不对. Floyd 判断 最小环 #include <iostrea ...

随机推荐

  1. cxImage控件使用

    属性: Picture:载入要显示的图片 Properties->Caption在没有内容的时候显示在图片框中间的文字 Properties->PopupMenuLayout->Me ...

  2. GUI库之认识Tkinter(一)

    一.介绍 Tkinter是Python默认的GUI库,我们经常使用的IDLE就是用Tkinter设计出来的,因此我们在使用的时候直接导入Tkinter模块就好了. 1.特点:可移植性.灵活性高 2.构 ...

  3. golang 编译或链接 c语言动态、静态库的方法, golang 与 c语言 相互调用

    1.golang链接c静态库的方法可以见这个示例: https://github.com/atercattus/go-static-link-example https://github.com/sh ...

  4. api-gateway-engine知识点(1)

    1     密钥绑定时,通过Channel 实现监控 后台发送数据 :      redisTemplate.convertAndSend(RedisMessageChannel.API_GATEWA ...

  5. 浅谈Python web框架

    一.Python web框架 Web Framework,Ruby的世界Rails一统江湖,而Python则是一个百花齐放的世界,各种micro-framework.framework不可胜数,不完全 ...

  6. Spring MVC定时服务

    spring-mvc-config.xml <context:component-scan base-package="com.bf" ></context:co ...

  7. spring注解注入的学习

    spring在开发中起到管理bean的作用,不管是web应用还是应用软件开发.注入有多种方式,其中注解注入最为受欢迎.(java api 在1.6版本以上才引入关键的注解类如:@Resource) 配 ...

  8. recover database noredo时报错ORA-19573

    环境: RHEL6.4 + Oracle 11.2.0.4 Primary RAC + Standby RAC 今天发现DG备库归档空间满,清理后发现备库出现GAP,需要从主库做基于SCN的增量备份进 ...

  9. 从0开始搭建vue+webpack脚手架(二)

    接着从0开始搭建vue+webpack脚手架(一) 三.配置webpack-dev-server 1. webpack-dev-server自带一个node的服务器, 项目在服务端运行的同时可以实现热 ...

  10. LeetCode13.罗马数字转整数

    罗马数字包含以下七种字符: I, V, X, L,C,D 和 M. 字符 数值 I 1 V 5 X 10 L 50 C 100 D 500 M 1000 例如, 罗马数字 2 写做 II ,即为两个并 ...