题目传送门
/*
最短路:Floyd算法模板题
*/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
using namespace std;
const int MAXN = + ;
const int INF = 0x3f3f3f3f;
double d[MAXN][MAXN];
int used[MAXN];
struct NODE
{
int x, y;
}node[MAXN];
double dis(int j, int i)
{
return sqrt ((node[j].x - node[i].x) * (node[j].x - node[i].x) + (node[j].y - node[i].y) * (node[j].y - node[i].y));
}
void Floyd_Warshall(int n)
{
for (int k=; k<=n; ++k)
{
for (int i=; i<=n-; ++i)
{
for (int j=i+; j<=n; ++j)
{
if (d[i][k] < d[i][j] && d[k][j] < d[i][j])
{
if (d[i][k] < d[k][j])
d[i][j] = d[j][i] = d[k][j];
else
d[i][j] = d[j][i] = d[i][k];
}
}
}
}
printf ("Frog Distance = %.3f\n", d[][]);
}
int main(void) //POJ 2253 Frogger
{
//freopen ("D.in", "r", stdin);
int n;
int cnt = ;
int first = ;
while (~scanf ("%d", &n) && n)
{
for (int i=; i<=n; ++i)
{
scanf ("%d%d", &node[i].x, &node[i].y);
}
for (int i=; i<=n-; ++i)
{
for (int j=i+; j<=n; ++j)
{
d[i][j] = d[j][i] = dis (i, j);
}
}
printf ("Scenario #%d\n", ++cnt);
Floyd_Warshall (n);
puts ("");
}
return ;
}
/*
Scenario #1
Frog Distance = 5.000
Scenario #2
Frog Distance = 1.414
*/