原题链接:http://poj.org/problem?id=2253

Frogger
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 30637   Accepted: 9883

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

题意

有个青蛙要从某个石头跳到另外一个石头,告诉你石头的坐标,求最小的跳跃范围。跳跃范围的定义是:对于任意一条可行路径中最长的跳跃。

题解

改造floyd,floyd是dp的思想,那么我们可以定义,dp[i][j]表示从i到j的最小跳跃范围,那么dp[i][j]=min(dp[i][j],max(dp[i][k],dp[k][j]))

代码

#include<iostream>
#include<queue>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#define INF 1008611
#define MAX_N 234
using namespace std; double f[MAX_N][MAX_N]; double x[MAX_N],y[MAX_N];
int n;
int cas=;
int main() {
while (true) {
scanf("%d", &n);
if (n == )break;
for (int i = ; i < n; i++)cin >> x[i] >> y[i];
for (int i = ; i < n; i++) {
f[i][i]=;
for (int j = ; j < n; j++)
f[i][j] = f[j][i] = sqrt(pow(x[i] - x[j], 2.0) + pow(y[i] - y[j], 2.0));
}
for (int k = ; k < n; k++)
for (int j = ; j < n; j++)
for (int i = ; i < n; i++)
f[i][j] = min(f[i][j], max(f[i][k], f[k][j]));
printf("Scenario #%d\nFrog Distance = %.3lf\n\n", ++cas, f[][]);
}
return ;
}

POJ 2253 Frogger Floyd的更多相关文章

  1. POJ 2253 Frogger floyd算法

    题目:click here 题意: 给出两只青蛙的坐标A.B,和其他的n-2个坐标,任意两坐标间是双向连通的.显然从A到B存在至少一条的通路,每一条通路的元素都是这条通路中前后两个点的距离,这些距离中 ...

  2. 最短路(Floyd_Warshall) POJ 2253 Frogger

    题目传送门 /* 最短路:Floyd算法模板题 */ #include <cstdio> #include <iostream> #include <algorithm& ...

  3. POJ 2253 Frogger ,poj3660Cow Contest(判断绝对顺序)(最短路,floyed)

    POJ 2253 Frogger题目意思就是求所有路径中最大路径中的最小值. #include<iostream> #include<cstdio> #include<s ...

  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

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

  7. poj 2253 Frogger 最小瓶颈路(变形的最小生成树 prim算法解决(需要很好的理解prim))

    传送门: http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissi ...

  8. poj 2253 Frogger (dijkstra最短路)

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

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

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

随机推荐

  1. GoF23种设计模式之行为型模式之访问者模式

    概述 表示一个作用于某对象结构中的各元素的操作. 它使你可以在不改变各元素的类的前提下定义作用于这些元素的新操作. 适用性 1.一个对象结构包含很多类对象,它们有不同的接口,而你想对这些对象实施一些依 ...

  2. 「新手必看」Python+Opencv实现摄像头调用RGB图像并转换成HSV模型

    在ROS机器人的应用开发中,调用摄像头进行机器视觉处理是比较常见的方法,现在把利用opencv和python语言实现摄像头调用并转换成HSV模型的方法分享出来,希望能对学习ROS机器人的新手们一点帮助 ...

  3. Flask初学者:Jinja2模板

    Python的Jinja2模板,其实就是在HTML文档中使用控制语句和表达语句替换HTML文档中的变量来控制HTML的显示格式,Python的Jinja2模板可以更加灵活和方便的控制HTML的显示,而 ...

  4. drf 认证功能

    drf(django rest-framework)认证组件 复习 HyperlinkedIdentityField ​```python 功能:快速生成连接 1. publish = seriali ...

  5. (转)iOS平台UDID方案比较

    苹果在iOS6中禁用了[UIDevice uniqueIdentifier],在iOS7中又把mac地址的获取给堵上了.没办法,毕竟人家是老大,说不让你用,你也没办法.   在这边总结一下现有的一部分 ...

  6. JFinal 结合Dubbo发生的一些问题

    1.java.lang.NoSuchMethodError: org.jboss.resteasy.specimpl.BuiltResponse.getHeaders()Ljavax/ws/rs/co ...

  7. Kattis - doubleclique (图论)

    From : North American Invitational Programming Contest 2018 给你一个图,以及它的补图.如果部分点在原图中是团,并且其他的所有点在补图中也是团 ...

  8. redis--py链接redis【转】

    请给原作者点赞--> 原文链接 一.redis redis是一个key-value存储系统.和Memcached类似,它支持存储的value类型相对更多,包括string(字符串).list(链 ...

  9. MyString的简单实现

    MyString.h 文件 #ifndef _STRING_H_ #define _STRING_H_ #include <iostream> using namespace std; c ...

  10. JS实现——俄罗斯方块

    把以下代码保存成Tetris.html文件,使用Google或360浏览器打开 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 4.0 Transit ...