http://poj.org/problem?id=2253
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 17536 | Accepted: 5717 |
Description
Unfortunately Fiona's stone is out of his jump range. Therefore Freddy considers to use other stones as intermediate stops and reach her by a sequence of several small jumps.
To execute a given sequence of jumps, a frog's jump range obviously must be at least as long as the longest jump occuring in the sequence.
The frog distance (humans also call it minimax distance) between two stones therefore is defined as the minimum necessary jump range over all possible paths between the two stones.
You are given the coordinates of Freddy's stone, Fiona's stone and all other stones in the lake. Your job is to compute the frog distance between Freddy's and Fiona's stone.
Input
Output
Sample Input
2 0 0 3 4 3 17 4 19 4 18 5 0
Sample Output
Scenario #1 Frog Distance = 5.000 Scenario #2 Frog Distance = 1.414
题意:给你坐标系中的n个点,求第1个点到第2个点的所有路径中 每条路径上的路径上最大边 最小是多少。就是求最短路径的 最大值。
#include<stdio.h>
#include<math.h>
#include<string.h>
struct coo{
double x;
double y;
}st[205];
double map[205][205];
int vis[205];
double dis[205];
int N;
double dist(int i,int j)//求两点间的距离
{
double x1,y1;
x1=pow(st[j].x-st[i].x,2.0);
y1=pow(st[j].y-st[i].y,2.0);
return sqrt(x1+y1);
}
double max(double a,double b)//求最大值
{
return a>b?a:b;
}
void dijkstra()
{
int i,j,u;
double min1;
dis[1]=0;
for(i=2;i<=N;i++)
{
dis[i]=map[1][i];
vis[i]=0;
}
vis[1]=1;
for(i=2;i<=N;i++)
{
min1=10000000;
for(j=1;j<=N;j++)
{
if(vis[j]==0 && dis[j]<min1)
{
u=j;
min1=dis[j];
}
}
if(u==2)
break;
vis[u]=1;
for(j=1;j<=N;j++)
{
if(vis[j]==0 && dis[j]>max(dis[u],map[u][j]))
{
dis[j]=max(dis[u],map[u][j]);
}
}
}
}
int main()
{
int i,j;
int Case=0;
while(scanf("%d",&N)!=EOF && N!=0)//有几个点
{
for(i=1;i<=N;i++)
scanf("%lf%lf",&st[i].x,&st[i].y);
memset(map,0,sizeof(map));//清零
for(i=1;i<=N;i++)
{
for(j=1;j<=N;j++)
{
map[i][j]=map[j][i]=dist(i,j);//构建邻接矩阵
}
}
dijkstra();
printf("Scenario #%d\nFrog Distance = %.3lf\n\n",++Case,dis[2]);
}
return 0;
}
2012.9.5
//prim()算法
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
#define MAXN 1100
int vis[MAXN];//标记访问
double lowcost[MAXN];//储存最小距离
double cost[MAXN][MAXN];//保存邻接矩阵
double x[MAXN],y[MAXN];//记录坐标
int n;
#define inf 0x3f3f3f3f
double maxx(double a,double b)
{
}
void prim()
{
}
int main()
{
}
//dijkstra()
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
const int inf =0x7f7f7f7f;
#define maxn 1010
int map[maxn][maxn];
int dis[maxn];
int n;
struct point
{
}pnt[maxn];
int _dist(point a,point b)
{
}
int max(int a,int b)
{
}
void dijkstra()
{
}
int main()
{
}
//floyd()算法
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
#define MAXN 1100
int vis[MAXN];//标记访问
double lowcost[MAXN];//储存最小距离
double cost[MAXN][MAXN];//保存邻接矩阵
double x[MAXN],y[MAXN];//记录坐标
int n;
#define inf 0x3f3f3f3f
double maxx(double a,double b)
{
}
void floyd()
{
}
int main()
{
}