Frogger
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions:57696   Accepted: 18104

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 思路
有i, j, k 三个点,如果i到j的距离比i到k,k到j的距离都大,那就先跳到k,再跳到j,否则,就直接跳到j。
由此我们可知,这个更新的方式,与最短路略有不同。 代码
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
double d[][];
int a[][],n;
int main()
{
int T;
T=;
while(cin>>n&&n){
T++;
memset(d,,sizeof(d));
for(int i=;i<=n;i++){
cin>>a[i][]>>a[i][];
}
for(int i=;i<=n;i++){
for(int k=i+;k<=n;k++){
d[i][k]=d[k][i]=sqrt((double)((a[i][]-a[k][])*(a[i][]-a[k][])+(a[i][]-a[k][])*(a[i][]-a[k][])));
}
}
for(int k=;k<=n;k++){
for(int j=;j<=n;j++){
for(int i=;i<=n;i++){
if(d[i][j]>d[i][k]&&d[i][j]>d[k][j]){
d[j][i]=d[i][j]=max(d[i][k],d[k][j]);
}
}
}
}
printf("Scenario #%d\nFrog Distance = %.3f\n\n",T,d[][]);
}
}
 

POJ 2253 Frogger (Floyd)的更多相关文章

  1. POJ 2253 Frogger(floyd)

    http://poj.org/problem?id=2253 题意 : 题目是说,有这样一只青蛙Freddy,他在一块石头上,他呢注意到青蛙Fiona在另一块石头上,想去拜访,但是两块石头太远了,所以 ...

  2. POJ 2253 Frogger(最小生成树)

    青蛙跳跃,题意大概是:青蛙从起点到终点进行一次或多次的跳跃,多次跳跃中肯定有最大的跳跃距离.求在所有的跳跃中,最小的最大跳跃距离SF-_-(不理解?看题目吧). 可以用最小生成树完成.以起点为根,生成 ...

  3. poj 2253 Frogger(floyd变形)

    题目链接:http://poj.org/problem?id=1797 题意:给出两只青蛙的坐标A.B,和其他的n-2个坐标,任一两个坐标点间都是双向连通的.显然从A到B存在至少一条的通路,每一条通路 ...

  4. POJ. 2253 Frogger (Dijkstra )

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

  5. POJ 2253 Frogger(dijkstra 最短路

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

  6. poj 2253 Frogger (dijkstra最短路)

    题目链接:http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissi ...

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

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

  8. [ACM] POJ 2253 Frogger (最短路径变形,每条通路中的最长边的最小值)

    Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 24879   Accepted: 8076 Descript ...

  9. POJ 2253 Frogger(Dijkstra变形——最短路径最大权值)

    题目链接: http://poj.org/problem?id=2253 Description Freddy Frog is sitting on a stone in the middle of ...

随机推荐

  1. 思维导图,UML图,程序流程图制作从入门到精通

    工具: https://www.processon.com/ 第一 用例图 第二 时序图 第三 流程图

  2. linux硬盘的分区、格式化、挂载以及LVM

    linux硬盘的分区.格式化.挂载以及LVM   多块硬盘的组合: 硬盘分两种:ide和scsi. ide硬盘: /dev/hda 第一块IDE硬盘 /dev/hdb 第二块IDE硬盘 ... /de ...

  3. vue循環語句

    迭代數組: v-for="site in sites”,sites表示源數組名,site表示數組元素: 迭代對象: v-for=“value in Object”, v-for=" ...

  4. C# Web开发中弹出对话框的函数[转载]

    public void Alert(string str_Message) { ClientScriptManager scriptManager =((Page)System.Web.HttpCon ...

  5. JSED204B

    简介 JESD204是一种连接数据转换器(ADC和DAC)和逻辑器件的高速串行接口,该标准的 B 修订版支持高达 12.5 Gbps串行数据速率,并可确保 JESD204 链路具有可重复的确定性延迟. ...

  6. 将自己的ubuntu18.04打包成镜像

    将自己的ubuntu18.04打包成镜像 2018年11月10日 10:40:06 舌耳 阅读数:1590 先下载remastersys wget ftp://ftp.gwdg.de/pub/linu ...

  7. windows开关机事件

    开关机事件.xml <ViewerConfig> <QueryConfig> <QueryParams> <Simple> <BySource&g ...

  8. Go中的Init函数

    init函数会在main函数执行之前进行执行.init用在设置包.初始化变量或者其他要在程序运行前优先完成的引导工作. 举例:在进行数据库注册驱动的时候. 这里有init函数 package post ...

  9. MVC 自定义 错误页面

    很多时候,我们需要自定义错误页面,用来当发生异常后引导用户进入一个比较友好的错误页面. 在这里,我归结一下我常用的2个方案 1   通过Global.asax 文件来处理异常信息(这个不管是 MVC ...

  10. LOJ2250 [ZJOI2017] 仙人掌【树形DP】【DFS树】

    题目分析: 不难注意到仙人掌边可以删掉.在森林中考虑树形DP. 题目中说边不能重复,但我们可以在结束后没覆盖的边覆盖一个重复边,不改变方案数. 接着将所有的边接到当前点,然后每两个方案可以任意拼接.然 ...