Frogger
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 34865   Accepted: 11192

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.
多组数据
每组第一行为整数n,表示石头数目。接下来n行每行两个整数xi和yi,表示第i块石头坐标。
输入文件最后一行为0

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

因为已经限定了两只青蛙在石头1和2上,所以是单源最短路径问题

跑了遍floyd就过了

求青蛙距离:map[i][j]=min(map[i][j],max(map[i][k],map[k][j])

 #include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int mxn=;
int x[mxn],y[mxn];//石头坐标
double mp[][];//图
int n;
double dis(int x1,int x2,int y1,int y2){//求两点间距离
return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
void cdis(){//将两点间距离存入邻接矩阵
memset(mp,,sizeof());
int i,j;
for(i=;i<=n;i++)
for(j=;j<=n;j++){
mp[i][j]=dis(x[i],x[j],y[i],y[j]);
}
return;
}
int main(){
int T=;
while(scanf("%d",&n) && n){
printf("Scenario #%d\n",++T);
int i,j;
for(i=;i<=n;i++){
scanf("%d%d",&x[i],&y[i]);
}
cdis();
for(int k=;k<=n;k++)
for(i=;i<=n;i++)
for(j=;j<=n;j++){
mp[i][j]=min(mp[i][j],max(mp[i][k],mp[k][j]));
// printf("%d %d %d\n",k,i,j);
// printf("%.3f %.3f %.3f\n",mp[i][j],mp[i][k],mp[k][j]);
}
printf("Frog Distance = %.3f\n\n",mp[][]);//注意空行
}
return ;
}

POJ2253 Frogger的更多相关文章

  1. POJ2253——Frogger(Floyd变形)

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

  2. POJ-2253 Frogger(最短路)

    https://vjudge.net/problem/POJ-2253 题意 公青蛙想到母青蛙那里去,期间有许多石头,公青蛙可以通过这些石头跳过去.问至少要跳的最大距离,即所有路径上石头间的最大距离的 ...

  3. poj2253 Frogger(Floyd)

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

  4. POJ2253 Frogger —— 最短路变形

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

  5. POJ-2253 Frogger dijsktra查找间隔最小的路径

    题目链接:https://cn.vjudge.net/problem/POJ-2253 题意 一只Forg需要从节点1走到节点n 现要找一条各个间隔最小的路径 问间隔最小是多少 思路 用dijsktr ...

  6. poj2253 Frogger(最短路变型或者最小生成树)

    /* 题意:就是源点到终点有多条的路径,每一条路径中都有一段最大的距离! 求这些路径中最大距离的最小值! Dijkstra, Floyd, spfa都是可以的!只不过是将松弛的条件变一下就行了! 想了 ...

  7. POJ2253 Frogger(最短路)

    题目链接. 题意: 从0号点,到1号点,找一条能通过的路,使得这条路中的最大的边,比其它所有可能的路中的边都小. 分析: 这题就是按着dijkstra写,写着写着觉得像是prim了. 其中d[n]表示 ...

  8. poj2253 Frogger Dijkstra变形

    题目链接:http://poj.org/problem?id=2253 就是求所有路径的最大边权值的最小值 处理时每次找出距离当前的已选的节点的最短距离,然后更新每个未选节点的值 代码: #inclu ...

  9. POJ-2253.Frogger.(求每条路径中最大值的最小值,最短路变形)

    做到了这个题,感觉网上的博客是真的水,只有kuangbin大神一句话就点醒了我,所以我写这篇博客是为了让最短路的入门者尽快脱坑...... 本题思路:本题是最短路的变形,要求出最短路中的最大跳跃距离, ...

随机推荐

  1. css3d

    立方体:http://sandbox.runjs.cn/show/1h6zvghj 原理分析:(左负右正) x:与屏幕水平:(在屏幕上) y:与屏幕水平方向垂直(在屏幕上) z:垂直于屏幕(在屏幕外) ...

  2. uniq-sort-awk

    题目:[百度搜狐面试题] 统计url出现次数 oldboy.log http://www.etiantain.org/index.html http://www.etiantain.org/1.htm ...

  3. c++ 标准库的各种容器(vector,deque,map,set,unordered_map,unordered_set,list)的性能考虑

    转自:http://blog.csdn.net/truexf/article/details/17303263 一.vector vector采用一段连续的内存来存储其元素,向vector添加元素的时 ...

  4. [WEB API] CLIENT 指定请求及回应格式(XML/JSON)

    [Web API] Client 指定请求及响应格式(xml/json) Web API 支持的格式请参考 http://www.asp.net/web-api/overview/formats-an ...

  5. UI设计师零基础入门到精通精品视频教程【155课高清完整版】

    [福吧资源网分享]课程是非常完整的,也是非常零基础的,适合任何学员,有需要的可以下载看看!课程目录:第1章 Adobe Photoshop CS6课时1 Adobe Photoshop CS6入门基础 ...

  6. java方法重载 与 重写

    class ChongZai{ public void a(int a); public void a(Strting a); public void a(int a,int b); } 如上就是一个 ...

  7. 学习笔记——Maven 命令行选项

    2014-10-09:更新裁剪反应堆具体用法 说明: 1.使用-选项时,和后面的参数之间可以不要空格.而使用--选项时,和后面的参数之    间必须有空格.如下面的例子: $ mvn help:des ...

  8. 优化Webstorm

    Webstorm这个编辑器还是很强大的,而且版本更新得快,支持最新的typescript,就是性能越来越低. 本文总结了一些优化Webstorm的有效方法,希望对大家有所帮助! 测试环境 Mac OS ...

  9. STM32的bulk双缓冲传输速度的讨论,硬件的坑永远填不完

    详情:http://bbs.21ic.com/forum.php?mod=viewthread&tid=109584   USB 1.0的最高12Mbps. USB 2.0的高速模式480Mb ...

  10. 《android基于andFix的热修复方案》思路篇

    1:需求背景 项目上线之后,发现BUG需要修复(比如安卓兼容性等测试难以发现的问题),频繁的更新影响用户体验 2:方案要求 静默下载,耗费流量少,打完补丁后立刻生效,不用重启apk 3:解决思路 3. ...