Frogger
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 25773   Accepted: 8374

Description

Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sitting on another stone. He plans to visit her, but since the water is dirty and full of tourists' sunscreen, he wants to avoid swimming and instead reach her by jumping. 
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

The input will contain one or more test cases. The first line of each test case will contain the number of stones n (2<=n<=200). The next n lines each contain two integers xi,yi (0 <= xi,yi <= 1000) representing the coordinates of stone #i. Stone #1 is Freddy's stone, stone #2 is Fiona's stone, the other n-2 stones are unoccupied. There's a blank line following each test case. Input is terminated by a value of zero (0) for n.

Output

For each test case, print a line saying "Scenario #x" and a line saying "Frog Distance = y" where x is replaced by the test case number (they are numbered from 1) and y is replaced by the appropriate real number, printed to three decimals. Put a blank line after each test case, even after the last one.

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

Source

 
题目大意:有两只青蛙和若干块石头,其中一只青蛙想去拜访另一只青蛙,现在已知这些东西的坐标,两只青蛙坐标分别是第一个和第二个坐标,并且这只青蛙可以借助任意石头的跳跃,而两只青蛙之间有若干通路,问两只的所有通路上的最大边,然后在通过这些最大边来找最短路。
从起点到终点会有很多路径,每条路径上的边有一个最大值,求这些最大值中的最小值。
也就是更新的边要保持最大边。
特别注意:这里我也不是很懂的地方,在最后输出的时候用%.3lf就是死命的wa,而改成%.3f就轻松ac了,其实不过在poj上是可以过得了,如果过不了再改也是可以的了,我是在专题里面一直wa,表示很无奈~
 
不多说了,看代码~
 #include <stdio.h>
#include <math.h>
const int INF=;
double map[][],node[],Min;
int n,vis[]; double Max(double a,double b)
{
return a>b?a:b;
} void dijkstra()
{
int i,j,k,m;
for (i=; i<n; i++)
{
node[i]=map[][i];
vis[i]=;
}
vis[]=;
for (k=; k<n; k++)
{
Min=INF;
m=-;
for (i=; i<n; i++)
if (!vis[i])
{
if (Min>node[i])
{
Min=node[i];
m=i;
}
}
if (m==-)
break;
vis[m]=;
//tm=m;
for (i=; i<n; i++)
{
if (!vis[i]&&Max(node[m],map[m][i])<node[i])
node[i]=Max(node[m],map[m][i]); }
}
} int main ()
{
double a[],b[];
int count=,i,j;
while (scanf("%d",&n),n)
{
for (i=; i<n; i++)
{
scanf("%lf%lf",&a[i],&b[i]);
}
for (i=; i<n; i++)
{
for (j=; j<n; j++)
{
map[i][j]=map[j][i]=(a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j]); }
}
dijkstra();
printf("Scenario #%d\n", ++count);
printf("Frog Distance = %.3f\n\n", sqrt(node[]));
}
return ;
}
 
 

poj 2253 Frogger (dijkstra最短路)的更多相关文章

  1. POJ 2253 ——Frogger——————【最短路、Dijkstra、最长边最小化】

    Frogger Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Stat ...

  2. POJ - 2253 Frogger(最短路Dijkstra or flod)

    题意:要从起点的石头跳到终点的石头,设The frog distance为从起点到终点的某一路径中两点间距离的最大值,问在从起点到终点的所有路径中The frog distance的最小值为多少. 分 ...

  3. POJ 2253 - Frogger - [dijkstra求最短路]

    Time Limit: 1000MS Memory Limit: 65536K Description Freddy Frog is sitting on a stone in the middle ...

  4. POJ 2253 Frogger【最短路变形——路径上最小的最大权】

    链接: http://poj.org/problem?id=2253 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22010#probl ...

  5. poj 2253 Frogger dijkstra算法实现

    点击打开链接 Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 21653   Accepted: 7042 D ...

  6. poj 2253 Frogger (最短路变种,连通图的最长边)

    题目 这里的dijsktra的变种代码是我看着自己打的,终于把代码和做法思路联系上了,也就是理解了算法——看来手跟着画一遍真的有助于理解. #define _CRT_SECURE_NO_WARNING ...

  7. POJ 2253 Frogger【最短路变形/最小生成树的最大权/最小瓶颈树/A到B多条路径中的最小的最长边】

    Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sit ...

  8. POJ 2253 Frogger(最短路&Floyd)题解

    题意:想给你公青蛙位置,再给你母青蛙位置,然后给你剩余位置,问你怎么走,公青蛙全力跳的的最远距离最小. 思路:这里不是求最短路径,而是要你找一条路,青蛙走这条路时,对他跳远要求最低.这个思想还是挺好迁 ...

  9. POJ 2253 Frogger(dijkstra 最短路

    POJ 2253 Frogger Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fion ...

  10. POJ. 2253 Frogger (Dijkstra )

    POJ. 2253 Frogger (Dijkstra ) 题意分析 首先给出n个点的坐标,其中第一个点的坐标为青蛙1的坐标,第二个点的坐标为青蛙2的坐标.给出的n个点,两两双向互通,求出由1到2可行 ...

随机推荐

  1. 【alpha】Scrum站立会议第4次....10.19

    小组名称:nice! 小组成员:李权 于淼 杨柳 刘芳芳 项目内容:约跑app(约吧--暂定) 1.任务进度 2.燃尽图 功能列表 1.登录注册 2.创建跑步计划 3.筛选跑友 4.加一起跑步的人为好 ...

  2. Nautilus-Share-Message: Called "net usershare info" but it failed: Failed to

    See what nautilus processes are running : ps aux | grep nautilus Kill all nautilus processes you see ...

  3. 阻塞 , 非阻塞 , 同步 ,异步 , I/O模型

    •阻塞,非阻塞:进程/线程要访问的数据是否就绪,进程/线程是否需要等待: •同步,异步:访问数据的方式,同步需要主动读写数据,在读写数据的过程中还是会阻塞:异步只需要I/O操作完成的通知,并不主动读写 ...

  4. Oracle基础 表分区

    Oracle基础 表分区 一.表分区 (一)表分区的分类 1.范围分区(range) 2.散列分区(hash) 3.列表分区(list) 4.复合分区:范围-哈希(range-hash).范围-列表( ...

  5. 关键系统的JVM参数推荐

    1. 性能篇 1.1 建议的性能参数 1. 取消偏向锁: -XX:-UseBiasedLocking JDK1.6开始默认打开的偏向锁,会尝试把锁赋给第一个访问它的线程,取消同步块上的synchron ...

  6. request设置属性 一般当做下一个页面的结果集

    request设置属性 一般当做下一个页面的结果集

  7. Go语言【第八篇】:Go语言变量作用域

    Go语言变量作用域 作用域为已声明标识符所表示的常量.类型.变量.函数或包在源代码中的作用范围,Go语言中变量可以在三个地方声明: 函数内定义的变量称为局部变量: 函数外定义的变量称为全局变量: 函数 ...

  8. 如何正确实现Page接口分页,用PageImpl 自定义分页

    /** * Constructor of {@code PageImpl}. * * @param content the content of this page, must not be {@li ...

  9. POJ3070:Fibonacci——题解

    http://poj.org/problem?id=3070 题目大意:求Fibonacci数列第n项,对10000取模. 矩阵乘法板子题……实在不知道写什么了. #include<iostre ...

  10. Codeforces VK Cup Finals #424 Div.1 A. Office Keys(DP)

    显然是不可能交叉取钥匙的,于是把钥匙和人都按坐标排序就可以DP了 钥匙可以不被取,于是f[i][j]表示前i个钥匙被j个人拿的时间 f[i][j]=min(f[i-1][j],max(f[i-1][j ...