hdu 1596 find the safest road (floyd)
2013-08-10 10:20
344 查看
我去,水过的!
C++提交4000ms,G++大于4500ms,擦!
水的!!!!!
#include<stdio.h>
#define max(a,b) a>b?a:b
double map[1010][1010];
int main()
{
int n,i,j,k,t;
int start,end;
while(scanf("%d",&n)!=EOF)
{
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
scanf("%lf",&map[i][j]);
for(k=1;k<=n;k++)
for(i=1;i<=n;i++)
{
if(map[i][k]>0.00000001)
for(j=1;j<=n;j++)
{
map[i][j]=max(map[i][j],map[i][k]*map[k][j]);
}
}
scanf("%d",&t);
for(i=0;i<t;i++)
{
scanf("%d%d",&start,&end);
if(map[start][end]<0.00000001)
printf("What a pity!\n");
else
printf("%.3lf\n",map[start][end]);
}
}
return 0;
}
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1596
C++提交4000ms,G++大于4500ms,擦!
水的!!!!!
#include<stdio.h>
#define max(a,b) a>b?a:b
double map[1010][1010];
int main()
{
int n,i,j,k,t;
int start,end;
while(scanf("%d",&n)!=EOF)
{
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
scanf("%lf",&map[i][j]);
for(k=1;k<=n;k++)
for(i=1;i<=n;i++)
{
if(map[i][k]>0.00000001)
for(j=1;j<=n;j++)
{
map[i][j]=max(map[i][j],map[i][k]*map[k][j]);
}
}
scanf("%d",&t);
for(i=0;i<t;i++)
{
scanf("%d%d",&start,&end);
if(map[start][end]<0.00000001)
printf("What a pity!\n");
else
printf("%.3lf\n",map[start][end]);
}
}
return 0;
}
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1596
相关文章推荐
- hdu 1596 find the safest road(dijkstra||floyd)
- HDU 1596(find the safest road) 最短路(SPFA&FLOYD&Dijkstra)
- hdu 1596 find the safest road (Floyd)
- hdu1596 find the safest road(最短路径floyd)
- HDU:1596 find the safest road(floyd最短路径算法+打表)
- HDU 1596 find the safest road -- floyd
- HDU 1596 find the safest road 【floyd】
- HDU 1596 find the safest road(Dijkstra,数据格式没定义好wrong了无数发)
- hdu 1596 find the safest road (最短路径dijkstra SPFA Floyd)
- find the safest road HDU - 1596
- hdu-1596-find the safest road
- hdu 1596 find the safest road(最长路)
- hdu-1596 find the safest road(SPFA做法)
- HDU 1596 find the safest road
- 【最短路+dijkstra+floyd+spfa】1596 find the safest road
- hdu 1596 find the safest road
- HDU 1596 find the safest road
- hdu 1596 find the safest road
- hdu 1596 find the safest road (最短路径)
- Hdu oj 1596 find the safest road(floyd)