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. 第三节:Vuejs常用特性2和图书案例

    一. 常用特性2 1. 监听器 用watch来响应数据的变化, 一般用于异步或者开销较大的操作, watch 中的属性 一定是data 中 已经存在的数据!!! 当需要监听一个对象的改变时,普通的wa ...

  2. Python3.5学习之旅——day3

    本节内容: 1.字符串操作 2.字典操作 3.集合 4.文件操作 5.字符编码与转码 6.函数与函数式编程 一.字符串操作 name='kobe' name.capitalize() 首字母大写 na ...

  3. ShellCode模板

    前言 在上一篇文章上使用到的添加用户的shellcode是怎么得到的呢? 先来拆分一下汇编的功能 ;寻找kernel32.dll的基地址 xor ecx,ecx mov eax,dword ptr f ...

  4. IP地址,子网掩码,网段表示法,默认网关,DNS服务器详解,DNS域名设计

    本文参考:<计算机网络: IP地址,子网掩码,网段表示法,默认网关,DNS服务器详解> IP地址 概述 计算机要实现网络通信,就必须要有一个用于快速定位的网络地址.IP地址就是计算机在网络 ...

  5. Node Sass does not yet support your current environment: Linux 64-bit with Unsupported runtime

    环境: ubuntu18 webstorm vue项目 报错原因: 缺少相关依赖 解决方法: npm rebuild node-sass 还未解决: npm uninstall --save node ...

  6. Java基础知识笔记第十章:输入输出流

    File类 文件的属性 目录 文件的创建与删除 运行可执行文件 文件字节输入流 文件字节输出流 文件字符输入输出流 缓冲流 随机流 数组流 数据流 对象流 序列化与对象克隆 使用Scanner解析文件 ...

  7. Struts2学习(六)

    拦截器原理 1.如图所示,Struts2拦截器的实现原理相对简单,当请求struts2的action时,Struts 2会查找配置文件,并根据其配置实例化相对的拦截器对象,然后串成一个列表,最后一个一 ...

  8. KEIL的一些函数

    一 Predefined Functions:http://www.keil.com/support/man/docs/uv4cl/uv4cl_df_predeffunct.htm 主要有三角/反三角 ...

  9. Python内置模块-logging

    一.初识logging模块 import logging logging.debug("debug message") #级别最低,只有在诊断问题时才有兴趣的详细信息. loggi ...

  10. 问题解决 : MyBatis一对一查询时,打印结果只有一条数据

    问题截图:修改后,结果返回条数正确 问题解决: 因为有重名的列,建议起个别名