#include
#include
#include
#include
#define N 205
#define inf 0x3f3f3f
using namespace std;
double e[N][N],dis[N];
int vis[N],x[N],y[N],n;
double edis(int i, int j){
return sqrt(double(x[i]-x[j])*(x[i]-x[j])+double(y[i]-y[j])*(y[i]-y[j]));
}
void dij(int s,int l)
{
memset(vis,0,sizeof(vis));
for(int i=1;i<=n;i++)
dis[i]=edis(s,i);
vis[s]=1;
for(int i=1;idis[j])
{
k=j;
minn=dis[j];
}
vis[k]=1;
for(int j=1;j<=n;j++)
dis[j]=min(dis[j],max(dis[k],edis(k,j)));
}
return ;
}
int main()
{
// freopen("1.txt","r",stdin);
int t=1;
while(~scanf("%d",&n)&&n)
{
memset(e,0,sizeof(e));
for(int i=1;i<=n;i++)
scanf("%d%d",&x[i],&y[i]);
dij(1,2);
printf("Scenario #%d\nFrog Distance = %.3lf\n\n",t++,dis[2]);
}
return 0;
}
#include
#include
#include
#include
#define N 205
#define inf 0x3f3f3f
using namespace std;
double e[N][N],dis[N];
int vis[N],x[N],y[N],n;
void dij(int s,int l)
{
memset(vis,0,sizeof(vis));
for(int i=1;i<=n;i++)
dis[i]=e[s][i];
vis[s]=1;
for(int i=1;idis[j])
{
k=j;
minn=dis[j];
}
vis[k]=1;
for(int j=1;j<=n;j++)
dis[j]=min(dis[j],max(dis[k],e[k][j]));
}
return ;
}
int main()
{
// freopen("1.txt","r",stdin);
int t=1;
while(~scanf("%d",&n)&&n)
{
memset(e,0,sizeof(e));
for(int i=1;i<=n;i++)
scanf("%d%d",&x[i],&y[i]);
for(int i=1;i
Bellman-Ford 写法
#include
#include
#include
#include
#include
#include