I've got BOUNDLESS WA !!
I think it's just an application of Floyd, so where's my wrong??
any comment is welcome !! Thanks in advance ~~
Code: Select all
// Q534 Frogger
// select the minimum of longest jumps ~~ minimax
#include<iostream>
#include<cstdlib>
#include<stdio.h>
#include<math.h>
#define MAX 201
using namespace std;
int n, index = 1;
double d[MAX][MAX], ar[MAX][2];
void Floyed_Warshall();
int min(int a, int b);
int max(int a, int b);
int main(int argc, char argv[])
{
while(cin >> n)
{
if(n == 0)
break;
for(int i = 1; i <= n; i++)
cin >> ar[i][0] >> ar[i][1];
for(int i = 1; i <= n; i++)
for(int j = i+1; j <= n; j++)
d[j][i] = d[i][j] =
sqrt((ar[j][1]-ar[i][1])*(ar[j][1]-ar[i][1])+(ar[j][0]-ar[i][0])*(ar[j][0]-ar[i][0]));
Floyed_Warshall();
cout << "Scenario #" << index++ << endl << "Frog Distance = ";
printf("%.3f\n\n",d[1][2]);
}
system("PAUSE");
return EXIT_SUCCESS;
}
void Floyed_Warshall()
{
for(int i = 1; i <= n; i++)
d[i][i] = 0;
for(int k = 1; k <= n; k++)
for(int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
d[i][j] = min(d[i][j], max(d[i][k], d[k][j]));
}
int min(int a, int b)
{
return (a < b) ? a: b;
}
int max(int a, int b)
{
return (a > b) ? a: b;
}