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. jsp 微信公众平台 token验证(php、jsp)(转载)

    微信公众平台现在推出自动回复消息接口,但是由于是接口内容用的是PHP语言写的,很多地方操作起来让本人这个对java比较熟悉的小伙很别扭,所以仿照PHP的接口代码做了一套jsp语言编写的接口. 首先先把 ...

  2. 当文本溢出包含的元素时加省略号之text-overflow

    text-overflow是css3的属性,用来处理文本溢出,默认裁剪处理,text-overflow属性只能用于block和inline-block元素,内联的和box,flex-flow:colu ...

  3. Ubuntu 下安装 apt-get install npm 失败的解决方案

    Ubuntu 下安装 apt-get  install npm 失败的解决方案: sudo apt-get remove nodejs npm ## remove existing nodejs an ...

  4. javascript发送验证码

    一个发送验证码的javascript代码 var T = 0; var handle = null; var event = null; $(function(){ $('#sendCode').cl ...

  5. GitLab/Git在AndroidStudio上的使用(转)

    1.在AndroidStudio上的配置GitLab 1)首先先将gitlab上的开发项目clone到本地(可以使用命令行或者管理工具,具体操作在GitLab中已经涉及,这里不再赘述),然后导入到An ...

  6. Python高手之路【八】python基础之requests模块

    1.Requests模块说明 Requests 是使用 Apache2 Licensed 许可证的 HTTP 库.用 Python 编写,真正的为人类着想. Python 标准库中的 urllib2  ...

  7. [教程]Oracle 11g Express 安装和使用教程

    使用工具的第一步就是安装工具,配置环境!下面就Oracle 11g Express的安装和简单实用做一简介. 一.下载安装过程 去oracle的官网下载Oracle 11g express,大概300 ...

  8. JNI 程序开发

    参考资料: http://blog.csdn.net/wwj_748/article/details/28136061 JNI_最简单的Java调用C/C++代码 http://blog.csdn.n ...

  9. GridView自定义分页

    CSS样式 首先把CSS样式代码粘贴过来: .gv { border: 1px solid #D7D7D7; font-size:12px; text-align:center; } .gvHeade ...

  10. 郝文菲get技能的经验--20155308

    郝文菲get技能的经验--20155308 比其他人更好的技能 谈到自己的特长,作为新一代成长的自己来说,有一箩筐的话可以说.但是若是谈到自己比大多数人更好的技能,我却觉得回答这个问题有很大的难度.当 ...