Frogger
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 31490   Accepted: 10150

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

这个题目有些绕,实际上的意思是从点1到点2有很多条路径,每一条抵达的路径都有一个最大值。要求的是这些最大值里面的最小值。

举个例子:点1到点2,有两条路径可以到达,一条是1->3->2,一条是1->4->2。

然后,1->3的值是5,3->2的值是3。那这条路径的最大值是5。之后1->4的距离是4。4->2的距离是3,那这条到达的路径最大值是4。题目要求的意思是求 5和4之间的最小值。
这个就是求最大值里面的最小值的意思。

代码:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#pragma warning(disable:4996)
using namespace std; int num;
double stone[205][3];
double dis[205][205]; int main()
{
int i,j,k,ist=1;
while(cin>>num)
{
if(num==0)
break;
cout<<"Scenario #"<<ist<<endl;
ist++;
cout<<"Frog Distance = "; for(i=1;i<=num;i++)
{
cin>>stone[i][1]>>stone[i][2];
} for(i=1;i<=num;i++)
{
for(j=i+1;j<=num;j++)
{
dis[j][i]=dis[i][j]=(double)sqrt((stone[i][1]-stone[j][1])*(stone[i][1]-stone[j][1])+(stone[i][2]-stone[j][2])*(stone[i][2]-stone[j][2]));
}
} for(k=1;k<=num;k++)
{
for(i=1;i<=num;i++)
{
for(j=1;j<=num;j++)
{
dis[i][j]=min(dis[i][j],max(dis[i][k],dis[k][j]));
}
}
} printf("%.3f",dis[1][2]);
cout<<endl;
cout<<endl;
}
return 0;
}


版权声明:本文为博主原创文章,未经博主允许不得转载。

POJ 2253:Frogger 求每一条路径最大值里面的最小值的更多相关文章

  1. POJ 2253 Frogger【最短路变形——路径上最小的最大权】

    链接: http://poj.org/problem?id=2253 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22010#probl ...

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

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

  3. POJ. 2253 Frogger (Dijkstra )

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

  4. 最短路(Floyd_Warshall) POJ 2253 Frogger

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

  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【最短路变形/最小生成树的最大权/最小瓶颈树/A到B多条路径中的最小的最长边】

    Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sit ...

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

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

  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. 解决误删libc.so.6过程的参考资料

    说说前因后果:因为之前安装了filezilla,发现安装不了,说是libc.so.6老旧了.差不多过了一个星期,也就是前天升级gcc成功后决定再解决这个问题.gcc升级成功后,决定创建新链接...然后 ...

  2. input和button 高度不一致问题

    原因是 input和button的高度计算不一样, input高度不包括border. button高度包括border. 解决方法: 1.box-sizing:border-box: 2.borde ...

  3. centos610最小安装之后 后续设置

    1.网络配置 centos选择最小桌面(如果不用到类似Oracle需要用到桌面的软件,则操作系统安装最小化安装)安装之后 查看网络配置如下: 截图显示网络并未启用. 2.开启网络设置 cd /etc/ ...

  4. Codeforces1107E. Vasya and Binary String

    题目链接 本题也是区间dp,但是需要保存的信息很多,是1还是0,有多少个连续的,那我们可以预处理,将所有的连续缩合成1个字符,那么字符串就变成了一个01交替的串,我们任意的消除1个部分,一定能引起连锁 ...

  5. Python之时间和日期模块

    1.import time 先要导入时间模块 1)time.time()得到当前的时间,返回的是时间戳,表示自1970年1月1日起到程序运行时的秒数 import time print(time.ti ...

  6. Vacuum Pump Manufacturer - Vacuum Pump Range Use: Considerations

    The vacuum pump is a versatile bottle that holds your lotion, shampoo and conditioner. Keep away fro ...

  7. 「模板」可持久化 HFQ-Treap

    老师用的是静态数组的写法,开了很多数组- 其实个人更倾向于 struct 或者用 class 封装起来. 但是鉴于太难打 好吧,是我懒得打. 然后就借鉴了老师的模板,写出了属于自己的 压行 风格. 代 ...

  8. flask blueprints

    flask blueprints 1.      flask blueprints 蓝图是一种网页模板的组合,可以方便的注册到flask中. 蓝图可以在文件中声明,也可以在包中声明,一般而言推荐在包中 ...

  9. 常用FTP命令汇总

    FTP是File Transport Protocol的简称,其作用是使连接到服务器上的客户可以在服务器和客户机间传输文件.除WWW服务外,FTP也算是使用最广泛的一种服务了.在cmd中ftp命令很多 ...

  10. 安卓LED跑马灯 超炫酷的表白神器破解版

    链接:https://pan.baidu.com/s/11Wxll4iLdcEPq0wUBK6Ong 提取码:all4