【HDU 1599】find the mincost route 【最小环】
来源:互联网 发布:淘宝是什么公司的 编辑:程序博客网 时间:2024/04/30 15:58
#include<bits/stdc++.h>using namespace std;#define M 1010#define N 110#define INF (1<<28)int n,m;int dp[N][N],f[N][N];void solve(){ for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) f[i][j]=dp[i][j]=INF; int a,b,c,ans=INF; for(int i=1;i<=m;i++) cin>>a>>b>>c,dp[a][b]>c?f[a][b]=f[b][a]=dp[a][b]=dp[b][a]=c:1; 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,dp[i][j]+f[i][k]+f[k][j]); } } for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ dp[i][j] = min(dp[i][j],dp[i][k]+dp[k][j]); } } } if(ans==INF)cout<<"It's impossible."<<endl; else cout<<ans<<endl;}int main(){ freopen("data.in","r",stdin); freopen("data.out","w",stdout); while(cin>>n>>m)solve(); return 0;}
免费赠送数据生成器拿好不写。
#!usr/bin/env python#-*- coding: utf-8 -*-import sysimport randomfp = open("data.in","w")sys.stdout = fpn = random.randint(1,101)m = random.randint(1,1001)print n,mfor i in range(0,n): for j in range(0,n): u = random.randint(1,n+1) v = random.randint(1,n+1) w = random.randint(1,101) print u,v,w print
对拍程序
@echo off:loopmkdata.pyhdu1599.exe~tmp.exefc data.out stddata.outif not errorlevel 1 goto looppausegoto loop
1 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
- 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【最短路】【无向图最小环】
- hdoj 1599 find the mincost route 【floyd + 最小环】
- HDOJ--1599--find the mincost route(floyd+最小环)
- hdu 1599 find the mincost route(找无向图最小环)
- HDU 1599 find the mincost route(无向图最小环)
- FusionCharts折线图,柱行图
- ionic 2 常用记录
- nginx rewrite重写规则配置
- 配色网站 【精品】
- spring和springmvc父子容器的关系
- 【HDU 1599】find the mincost route 【最小环】
- 基类指针和子类指针相互赋值
- java 计算两个数的百分比,以百分号显示
- Hadoop概述
- RGB到HSI转换
- leetcode 345
- android 事件分发机制
- Validate Binary Search Tree
- 数据存储之SwiftJSON