Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 30089 | Accepted: 9708 |
Description
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
说一下题意,给第一点是青蛙的坐标,第二个是妹子的坐标,其他的点是石头的坐标,现在要问青蛙到妹子的地方,至少需要跳的最大距离,不是最短路问题,路可以很长,跳的石头很多,要求是跳的最大距离,最小,可以构造包括妹子点的最小生成树,然后看下,目前已经连上点上的最大距离,还有一点,用G++的话用f,C++的话用lf可以A,G++会WA,
#include
#include
#include
#include
#define MAX 0x3f3f3f3f
struct node
{
double x, y;
} ls[210];
double map[250][250];
int n;
double dis[210];
int bj[250];
int kk = 0;
void Dijk()
{
int pos = 0;
memset(bj,0,sizeof(bj));
memset(dis,0,sizeof(dis));
for(int i = 0; i < n; i++)
dis[i] = map[pos][i];
bj[pos] = 1;
double ans=0;
for(int i = 0; i < n-1; i++)
{
double min = MAX;
for(int j = 0; j < n; j++)
{
if(min > dis[j] && !bj[j])
{
min = dis[pos = j];
}
}
bj[pos] = 1;
if(min>ans)
ans=min;
if(pos == 1)
break;
for(int j = 0; j < n; j++)
{
if(dis[j] > map[pos][j]&& !bj[j])
{
dis[j] = map[pos][j];
}
}
}
printf("Scenario #%d\n",++kk);
printf("Frog Distance = %.3lf\n",ans);
printf("\n");
}
int main()
{
kk = 0;
while(~scanf("%d",&n)&&n)
{
int i,j;
for(i = 0; i < n; i++)
scanf("%lf%lf",&ls[i].x,&ls[i].y);
for(i = 0; i < n; i++)
for(j = i; j < n; j++)
{
map[i][j] = sqrt(pow((ls[i].x - ls[j].x),2)+pow((ls[i].y -ls[j].y),2));
map[j][i] = sqrt(pow((ls[i].x - ls[j].x),2)+pow((ls[i].y -ls[j].y),2));
}
Dijk();
}
return 0;
}