Frogger

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

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.
 
这道题的题意不好懂。。。
重点理解下面一段:
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. 
由1到2存在路经p1,p2,...,pm。路径pi中的“longest jump”为di,则最终答案为min(d1,d2,...,dm)
AC Code:
 #include <iostream>
#include <algorithm>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath> using namespace std; const int sz = ;
const double inf = 10.0e8;
double d[sz][sz], x[sz], y[sz];
int n; void get_dist(int i, int j)
{
d[i][j] = d[j][i] = sqrt((x[i] - x[j]) * (x[i] - x[j]) +
(y[i] - y[j]) * (y[i] - y[j]));
} void floyd()
{
for(int k = ; k <= n; k++){
for(int i = ; i <= n; i++){
for(int j = ; j <= n; j++){
d[i][j] = min(d[i][j], max(d[i][k], d[k][j]));
}
}
}
} int main()
{
int ca = ;
while(scanf("%d", &n) && n){
for(int i = ; i <= n; i++){
for(int j = ; j <= n; j++){
d[i][j] = inf;
}
d[i][i] = 0.0;
}
for(int i = ; i <= n; i++){
scanf("%lf %lf", x + i, y + i);
for(int j = i - ; j > ; j--){
get_dist(i, j);
}
}
floyd();
printf("Scenario #%d\nFrog Distance = %.3lf\n\n", ca++, d[][]);
}
return ;
}
 

Frogger(floyd变形)的更多相关文章

  1. POJ2253——Frogger(Floyd变形)

    Frogger DescriptionFreddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fi ...

  2. UVA10048 Audiophobia[Floyd变形]

    UVA - 10048 Audiophobia Consider yourself lucky! Consider yourself lucky to be still breathing and h ...

  3. poj 2253 Frogger(floyd变形)

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

  4. hdu 1596(Floyd 变形)

    http://acm.hdu.edu.cn/showproblem.php?pid=1596 find the safest road Time Limit: 10000/5000 MS (Java/ ...

  5. hdu 1217 (Floyd变形)

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=1217 Arbitrage Time Limit: 2000/1000 MS (Java/Others)   ...

  6. poj2253 Frogger(Floyd)

    题目链接 http://poj.org/problem?id=2253 题意 给出青蛙A,B和若干石头的坐标,现在青蛙A要跳到青蛙B所在的石头上,求出所有路径中最远那一跳的最小值. 思路 Floyd算 ...

  7. POJ 2253 Frogger Floyd

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

  8. UVa 10048 (Floyd变形) Audiophobia

    题意: 给一个带权无向图,和一些询问,每次询问两个点之间最大权的最小路径. 分析: 紫书上的题解是错误的,应该是把原算法中的加号变成max即可.但推理过程还是类似的,如果理解了Floyd算法的话,这个 ...

  9. find the mincost route(floyd变形 无向图最小环)

    Time Limit: 1000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission( ...

随机推荐

  1. Java程序员的日常 —— static的用法讲解实践

    之前文章说过Java中static的作用,有朋友想看个例子.于是便抽空写了个小栗子 代码 package xing.test.thinking.chap5; class A{ public A() { ...

  2. 【原创】jmeter3.0在beanshell中输入中文乱码以及字体大小的更改

    我使用的是最新的jmeter3.0版本,新建一个beanshell sampler,在里面输入中文,发现显示的是乱码,而且字体非常小,看着吃力,调研了一下,可以在bin/jmeter.properti ...

  3. [推荐]PaaS技术知识贴

    [推荐]PaaS技术知识贴 云计算PaaS技术与应用 http://wenku.baidu.com/view/08f77eefaeaad1f346933f20?fr=prin大型WEB网站架构深入分析 ...

  4. IUnknown—COM和MFC

    http://www.vckbase.com/index.php/wv/60 问题: 我用MFC编写COM程序有一段时间了,知道如何使用宏和嵌套类,以及如何在嵌套类中处理IUnknown接口,但对IU ...

  5. java protected 与默认权限的区别

    作用域   当前类    同package   子孙类 其他package  public √   √  √ √  protected √ √ √ ×  friendly(default) √ √ × ...

  6. VAG DMA protocol

    Func 0a - RAM Read 0A Func 0a - ROM Read 0A Func 0a - EEPROM Read FD Func 0C xx - EEPROM Write 0A Fu ...

  7. Bilateral Filtering(双边滤波) for SSAO(转)

    原文链接:http://blog.csdn.net/bugrunner/article/details/7170471 另外一篇相似的英文资料:http://homepages.inf.ed.ac.u ...

  8. Crontab中shell每分钟执行一次HDFS文件上传不执行的解决方案

    一.Crontab -e 加入输出Log */1 * * * * /qiwen_list/upload_to_hdfs.sh > /qiwen_list/mapred.log 2>& ...

  9. JXLS 双循环模板

    商户名称 门店代码 时间 金额 <jx:forEach items="${resultList}" var="l">       ${l.name} ...

  10. JIRA 6.3.6版本部署

    JIRA 6.3.6版本部署 部署环境:Ubuntu Server .JDK1.7 JIRA文件:atlassian-jira-6.3.6.tar.gz 下载地址:百度云网盘地址http://pan. ...