hdu1596 find the safest road
来源:互联网 发布:郭靖黄蓉爱情知乎 编辑:程序博客网 时间:2024/05/21 09:50
//最大安全系数;dijkstra由最小路径改成最大路径
#include <stdio.h>#define INF -99.0#define MAXN 1002double map[MAXN][MAXN],safe[MAXN];int visited[MAXN];void Dijkstra(int s,int t,int n){int i,j,u;double max;for (i=1;i<=n;i++){safe[i]=map[s][i];visited[i]=0;}visited[s]=1;safe[s]=1;for (i=1;i<=n;i++){max=INF;for (j=1;j<=n;j++){if(!visited[j]&&max<safe[j]){max=safe[j];u=j;}}visited[u]=1;if(max==INF)break;for(j=1;j<=n;j++)if(!visited[j]&&safe[j]<map[u][j]*safe[u])safe[j]=map[u][j]*safe[u];}}int main(){int n,i,j,Q,st,end;while(scanf("%d",&n)!=EOF){for (i=1;i<=n;i++){for(j=1;j<=n;j++)scanf("%lf",&map[i][j]);}scanf("%d",&Q); while(Q--){scanf("%d %d",&st,&end);Dijkstra(st,end,n);if(safe[end])printf("%.3lf\n",safe[end]);elseprintf("What a pity!\n");}}return 0;}
- hdu1596 find the safest road
- hdu1596 find the safest road
- HDU1596---find the safest road
- hdu1596 find the safest road
- [hdu1596] find the safest road
- HDU1596 find the safest road
- HDU1596 find the safest road
- HDU1596-find the safest road
- hdu1596 find the safest road
- 【SPFA】 hdu1596 find the safest road
- find the safest road hdu1596 最短路
- HDU1596:find the safest road(Dijkstra)
- hdu1596——find the safest road
- hdu1596 find the safest road--多源最短路径
- HDU1596 find the safest road(floyd)
- HDU1596 find the safest road(最短路)
- hdu1596 find the safest road 最短路dijkstra
- hdu1596 find the safest road 最短路也能求最大值
- unity3D入门系列十三,如何制作天空盒(SkyBox)(英文)
- 杭电 HDU 1010 Tempter of the Bone
- Oracle Database 11g Release 2 RAC On Oracle Linux 5.8 Using VirtualBox
- Trie树的双数组实现
- v6eval编译问题
- hdu1596 find the safest road
- String和StringBuffer的区别
- UVa 11524 - In-Circle
- hdu2444 判断二分图+最大匹配
- 认清营销、销售和广告的庐山真面目
- css和js的浏览器不兼容问题汇总
- I2C总线原理及应用实例
- WPS设置首字母自动大写转换
- c语言要点摘录(21~24 数组与指针-上)