N times the table, or found the error, the original is the Floyd () written in the loop body ....
Shortcomings, a lot of advice.
14481443 2015-08-12 17:12:05 Accepted 1596 3588MS 15960K 1010 B C + +
#include <iostream>
#include <cstdio>
#include <queue>
#include <vector>
using namespace Std;
const int MAXN = 1005;
const int INF = 0XFFFFFF;
int n;
Double MAPS[MAXN][MAXN];
Double DIST[MAXN][MAXN];
void Floyd () {
for (int i = 1; I <= n; i++) {
for (Int J =1;j<=n; J + +) {
DIST[I][J] = Maps[i][j];
}
}
for (int k = 1; k <= N; k++) {
for (int i = 1; I <= n; i++) {
for (int j = 1; J <= N; j + +) {
if (Dist[i][j] < INF && Dist[k][j] <inf)
DIST[I][J] =max (Dist[i][j],dist[i][k] *dist[k][j]);
}
}
}
}
int main () {
int m, S, E;
while (scanf ("%d", &n)!=eof) {
memset (maps,0,sizeof (maps));
for (int i = 1; I <= n; i++) {
for (int j = 1; J <= N; j + +) {
scanf ("%lf", &maps[i][j]);
}
}
scanf ("%d", &m);
Floyd ();
while (m--) {
scanf ("%d%d", &s, &e);
if (dist[s][e] = = 0) {
printf ("What a pity!\n");
}else {
printf ("%.3lf\n", Dist[s][e]);
}
}
}
return 0;
}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
hdu1596 Find the safest road