B - Frogger

#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
double map[205][205];
int n;
struct edge{
    int x,y;
}s[205];
int main(){
    int cas=0;
    while(scanf("%d",&n)&&n){
        for(int i=1;i<=n;i++)
            scanf("%d%d",&s[i].x,&s[i].y);
        for(int i=1;i<=n;i++)
            for(int j=i+1;j<=n;j++)
                map[i][j]=map[j][i]=sqrt(double(s[i].x-s[j].x)*(s[i].x-s[j].x)+double(s[i].y-s[j].y)*(s[i].y-s[j].y));
        for(int k=1;k<=n;k++)
            for(int i=1;i<=n-1;i++)
                for(int j=1;j<=n;j++)
                    if(map[i][j]>map[i][k]&&map[i][j]>map[k][j]){
                        if(map[i][k]>map[k][j])    map[j][i]=map[i][j]=map[i][k];
                        else    map[j][i]=map[i][j]=map[k][j];
                    }
        printf("Scenario #%d\n",++cas);
        printf("Frog Distance = %.3f\n\n",map[1][2]);
    }
    return 0;                                    
}

 

posted @ 2018-02-27 16:27  一蓑烟雨任生平  阅读(450)  评论(0编辑  收藏  举报