Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 28802   Accepted: 9353

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
这题可以用Dijkstra,将松弛条件改一下就可以了,改成
          if(dis[j]>max(dis[stone],map[stone][j])&&(vis[j]==0)){
dis[j]=max(dis[stone],map[stone][j]);
}
这样的结果就是求得能到达这点的路径上的最长边的最小值,求输出时要注意格式
 #include <iostream>
#include<math.h>
#include<limits.h>
#include<algorithm>
#include<iomanip>
using namespace std;
int num;
int vis[],stone[][];
int map[][],dis[];
int Dijkstra(){
for(int i=;i<num;i++){
dis[i]=INT_MAX;
vis[i]=;
}
dis[]=;
for(int i=;i<num;i++){
int min=INT_MAX;
int stone;
for(int j=;j<num;j++){
if((vis[j]==)&&min>dis[j]){
stone=j;
min=dis[j];
}
}
vis[stone]=;
if(min==INT_MAX)
break;
for(int j=;j<num;j++){
if(dis[j]>max(dis[stone],map[stone][j])&&(vis[j]==)){
dis[j]=max(dis[stone],map[stone][j]);
}
}
}
return dis[];
} int main() { cin>>num;
int count=;
while(num){
for(int i=;i<num;i++){
cin>>stone[i][]>>stone[i][];
}
for(int i=;i<num;i++){
for(int j=;j<num;j++){
map[i][j]=pow((stone[i][]-stone[j][]),)+pow((stone[i][]-stone[j][]),);
}
}
float fdis=sqrt(Dijkstra());
cout<<fixed;
cout<<"Scenario #"<<count<<endl<<"Frog Distance = "<<setprecision()<<fdis<<endl<<endl; count++;
cin>>num;
} return ;
}

Frogger - poj 2253 (Dijkstra)的更多相关文章

  1. Poj(2253),Dijkstra松弛条件的变形

    题目链接:http://poj.org/problem?id=2253 题意: 给出两只青蛙的坐标A.B,和其他的n-2个坐标,任一两个坐标点间都是双向连通的.显然从A到B存在至少一条的通路,每一条通 ...

  2. Frogger POJ - 2253(求两个石头之间”所有通路中最长边中“的最小边)

    题意 ​ 题目主要说的是,有两只青蛙,在两个石头上,他们之间也有一些石头,一只青蛙要想到达另一只青蛙所在地方,必须跳在石头上.题目中给出了两只青蛙的初始位置,以及剩余石头的位置,问一只青蛙到达另一只青 ...

  3. kuangbin专题专题四 Frogger POJ - 2253

    题目链接:https://vjudge.net/problem/POJ-2253 思路: 从一号到二号石头的所有路线中,每条路线中都个子选出该路线中两点通路的最长距离,并在这些选出的最长距离选出最短路 ...

  4. floyd类型题UVa-10099-The Tourist Guide +Frogger POJ - 2253

    The Tourist Guide Mr. G. works as a tourist guide. His current assignment is to take some tourists f ...

  5. Frogger POJ - 2253

    题意 给你n个点,1为起点,2为终点,要求所有1到2所有路径中每条路径上最大值的最小值. 思路 不想打最短路 跑一边最小生成树,再扫一遍1到2的路径,取最大值即可 注意g++要用%f输出!!! 常数巨 ...

  6. POJ. 2253 Frogger (Dijkstra )

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

  7. POJ 2253 ——Frogger——————【最短路、Dijkstra、最长边最小化】

    Frogger Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Stat ...

  8. POJ 2253 Frogger(dijkstra 最短路

    POJ 2253 Frogger Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fion ...

  9. 最短路(Floyd_Warshall) POJ 2253 Frogger

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

随机推荐

  1. 最近公共祖先 Least Common Ancestors(LCA)算法 --- 与RMQ问题的转换

    [简介] LCA(T,u,v):在有根树T中,询问一个距离根最远的结点x,使得x同时为结点u.v的祖先. RMQ(A,i,j):对于线性序列A中,询问区间[i,j]上的最值.见我的博客---RMQ - ...

  2. apache mod_speling.so 忽略URL大小写(自动纠错)

    apache mod_speling.so 忽略URL大小写(自动纠错) 打开配置文件  httpd.conf 加入 LoadModule speling_module modules/mod_spe ...

  3. 1.NFC入门

    1.什么是NFC? 近距离无线通信技术(Near Field Communication,NFC).NFC提供了一种简单的.非触控式的解决方案,可以让消费者简单直观地交换信息.访问内容与服务. 2.运 ...

  4. 【安居客】资深PHP软件开发工程师

    工作职责: 1.网站项目的开发和维护: 2.负责技术部软件开发架构设计: 3.负责生产环境.测试环境和生产环境服务器运维和优化: 4.负责研究较前沿和复杂的技术运用: 岗位要求: 1.熟悉 PHP 程 ...

  5. [置顶] kubernetes资源类型--pod和job

    pod Pod是K8S的最小操作单元,一个Pod可以由一个或多个容器组成:整个K8S系统都是围绕着Pod展开的,比如如何部署运行Pod.如何保证Pod的数量.如何访问Pod等. 特点 Pod是能够被创 ...

  6. win10安装nodejs

    https://jingyan.baidu.com/article/b0b63dbfca599a4a483070a5.html 1 去官网下载对应版本的msi文件 2安装,path会自动设置 3 检验 ...

  7. 常用函数 __MySQL必知必会

    ----------------------使用数据处理函数 ---------------------- 常见的文本处理函数 Left() 返回串左边的字符Length() 返回串的长度Locate ...

  8. python装饰器的作用

    常见装饰器:内置装饰器:类装饰器.函数装饰器.带参数的函数装饰器 装饰器本质上是一个Python函数,它可以让其他函数在不需要做任何代码变动的前提下增加额外功能,装饰器的返回值也是一个函数对象.它经常 ...

  9. Section Formula

    https://brilliant.org/wiki/section-formula/

  10. SpringMVC处理MYSQL BLOB字段的上传

    任务: uos.docfile的content字段是longblob类型的,通过页面将文件存储到这个字段里. 页面代码: <div class="box"> <d ...