# UVa 10803 - Thunder Mountain

請你給出所有點間最短距離的最大值。

首先建圖，然後將大於10的邊都定義成oo，求解最短路，輸出最短路中的最大值即可。

#include <cstring>
#include <cstdio>
#include <cmath>

const double oo = 50000;

typedef struct _point
{
double x,y;
}point;
point  P[101];

double dist[101][101];

int main()
{
int T,n;
while (~scanf("%d",&T))
for (int t = 1; t <= T; ++ t) {
//input
scanf("%d",&n);
for (int i = 0; i < n; ++ i)
scanf("%lf%lf",&P[i].x,&P[i].y);
//initial
for (int i = 0; i < n; ++ i)
for (int j = 0; j < n; ++ j) {
dist[i][j] = sqrt((P[i].x-P[j].x)*(P[i].x-P[j].x)+(P[i].y-P[j].y)*(P[i].y-P[j].y));
if (dist[i][j] > 10.0)
dist[i][j] = oo;
}
//floyd
for (int k = 0; k < n; ++ k)
for (int i = 0; i < n; ++ i)
for (int j = 0; j < n; ++ j)
if (dist[i][j] > dist[i][k]+dist[k][j])
dist[i][j] = dist[i][k]+dist[k][j];
//find max
double Max = 0;
for (int i = 0; i < n; ++ i)
for (int j = 0; j < n; ++ j)
if (Max < dist[i][j])
Max = dist[i][j];
//output
printf("Case #%d:\n",t);
if (Max == oo)
printf("Send Kurdy\n\n");
else printf("%.4lf\n\n",Max);
}
return 0;
}


01-25 176

11-10 993

03-16 765

11-28 1435

07-24 419

01-02 406

10-18 1213

12-02 246

12-04 673

11-05 560