-
Notifications
You must be signed in to change notification settings - Fork 0
/
10803 - Thunder Mountain.cpp
47 lines (40 loc) · 1.13 KB
/
10803 - Thunder Mountain.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <bits/stdc++.h>
#define N 105
#define INF 1000000
using namespace std;
int u[N], v[N], n;
double graph[N][N];
double Distance(int i, int j) {
return sqrt((u[i]-u[j])*(u[i]-u[j]) + (v[i]-v[j])*(v[i]-v[j]));
}
int main()
{
int kase, kk, i, j, k;
cin >> kase;
for (kk=1; kk<=kase; kk++) {
cin >> n;
for (i=1; i<=n; i++)
cin >> u[i] >> v[i];
for (i=1; i<=n; i++)
for (j=i; j<=n; j++) {
graph[i][j] = Distance(i, j);
if (graph[i][j]>10) graph[i][j] = INF;
graph[j][i] = graph[i][j];
}
for (k=1; k<=n; k++)
for (i=1; i<=n; i++)
for (j=1; j<=n; j++)
graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
double ans = 0.0;
for (i=1; i<=n; i++)
for (j=i; j<=n; j++) {
ans = max(ans, graph[i][j]);
}
printf("Case #%d:\n", kk);
if (ans==INF)
puts("Send Kurdy");
else
printf("%.4lf\n", ans);
cout << endl;
}
}