/*floyd*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
using namespace std;
const int maxn = 205;
const int inf = 1 << 30;
double g[maxn][maxn];
int c;
struct node {
double x, y;
};
node s[maxn];
double walk(int i, int j)
{
double len = sqrt((s[i].x - s[j].x) * (s[i].x - s[j].x) + (s[i].y - s[j].y) * (s[i].y - s[j].y));
return 60 * len / 10000;
}
double subway(int i, int j)
{
double len = sqrt((s[i].x - s[j].x) * (s[i].x - s[j].x) + (s[i].y - s[j].y) * (s[i].y - s[j].y));
return 60 * len / 40000;
}
void floyd()
{
for (int k = 1; k <= c; ++k) {
for (int i = 1; i <= c; ++i) {
for (int j = 1; j <= c; ++j) {
g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
}
}
}
return;
}
int main()
{
while (cin >> s[1].x >> s[1].y >> s[2].x >> s[2].y) {
g[1][2] = g[2][1] = walk(1, 2);
int j = 0, x, y;
c = 3;
while (cin >> x >> y) {
if (x == -1 && y == -1)
j = 0;
else {
s[c].x = x; s[c].y = y;
for (int i = 1; i < c - j; ++i)
g[i][c] = g[c][i] = walk(i, c);
for (int i = c - j; i < c; ++i)
g[i][c] = g[c][i] = subway(i, c);
j = 1; ++c;
}
}
--c;
floyd();
printf("%.0f\n", g[1][2]);
}
return 0;
}
POJ2502 Subway flody
最新推荐文章于 2020-08-02 00:25:03 发布