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. WPF TreeGrid Binding 简易实现方式

    在設計TreeView編輯狀況下,希望 TreeItemName 后续的编辑框 复选框 可以整齐排列. 参考微软提供的TREELISTVIEW,发现它是根据层级关系调整Margin 属性. 我这边按照 ...

  2. MySQL之多表查询(笛卡尔积查询、内连接、外连接(左外连接,右外连接)、union、union all )

    多表查询 测试数据 create table emp (id int,name char(10),sex char,dept_id int); insert emp values(1,"大黄 ...

  3. ab的压力测试(转)

    其中-n代表请求数,-c代表并发数 返回结果: ##首先是apache的版本信息 This is ApacheBench, Version 2.3 <Revision:655654> Co ...

  4. python打印日志log

    整理一个python打印日志的配置文件,是我喜欢的格式. # coding:utf-8 # 2019/11/7 09:19 # huihui # ref: import logging LOG_FOR ...

  5. mysql 统计索引执行情况

    select distinct b.TABLE_SCHEMA,b.TABLE_NAME , b.INDEX_NAME , a.count_starfrom performance_schema.tab ...

  6. NB-IOT学习

    一 信号穿透力强,覆盖面广(基站少成本低).低功耗(eDRX/PSM省电技术).适合小流量时延要求不高(10s.) 二 主要芯片: 华为:Hi2110/2115,基于此的模组有:中移的M5310 移芯 ...

  7. 《容器化.NET应用架构指南》脑图学习笔记(第一部分)

    一.关于这本官方“圣经” 作为.NET程序员,对于微软官方推动的架构示例总是特别关注,从PetShop到MusicStore再到eShopOnContainers,每一次关注,都会了解到业界最新的架构 ...

  8. C-当把数组传递给函数

    #include <stdio.h> /** * C语言中,数组的名称就是 一连串连续内存的起始地址, * 因此给数组传递给函数,传递的就是数组元素类型的指针 */ ]); void he ...

  9. 58按之字形顺序打印二叉树 +队列访问使用front和back,栈才是top

    题目描述 请实现一个函数按照之字形打印二叉树,即第一行按照从左到右的顺序打印,第二层按照从右至左的顺序打印,第三行按照从左到右的顺序打印,其他行以此类推.   思路:最暴力的方法就是使用队列进行层次遍 ...

  10. Java入门程序“hello,world!”

    1.程序开发步骤说明 开发环境已经搭建完毕,可以开发我们第一个Java程序了. Java程序开发三步骤:编写.编译.运行.(图片介绍)   2.编写Java程序 新建一个普通的记事本,给其命名为Hel ...