POJ 2253 Frogger

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
#include<iostream>
#include<cmath>
#include<cstdio>
#define inf 10000000
using namespace std;
struct ac{
int x,y;
}a[];
double temp[][],dis[];
void dijkstra(int n){
double minn;
int flag,vis[]={};
for(int i = ;i < n;++i)dis[i]=temp[][i];
for(int i = ;i < n-;++i){
minn=inf;flag=;
for(int j = ;j < n;++j){
if(minn>dis[j]&&!vis[j])minn=dis[j],flag=j;
}
vis[flag]=;
for(int j = ;j < n;++j){
dis[j]=min(dis[j],max(dis[flag],temp[flag][j]));
}
}
}
int main()
{
int m,ans=;
while(cin>>m&&m){
for(int i = ;i < m;++i)cin>>a[i].x>>a[i].y;
// ac tempp=a[m-1];a[m-1]=a[1],a[1]=tempp;
for(int i = ;i < m;++i){
for(int j = ;j < m;++j){
temp[i][j]=temp[j][i]=sqrt((a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y));
}
}
dijkstra(m);
if(ans!=)cout<<endl;
printf("Scenario #%d\nFrog Distance = %.3f\n",ans++,dis[]);
}
}

AC代码

没想到最后是被输出格式卡了。。晕。。

POJ 2253 Frogger(dijkstra 最短路的更多相关文章

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

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

  2. POJ - 2253 Frogger(最短路Dijkstra or flod)

    题意:要从起点的石头跳到终点的石头,设The frog distance为从起点到终点的某一路径中两点间距离的最大值,问在从起点到终点的所有路径中The frog distance的最小值为多少. 分 ...

  3. POJ 2253 - Frogger - [dijkstra求最短路]

    Time Limit: 1000MS Memory Limit: 65536K Description Freddy Frog is sitting on a stone in the middle ...

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

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

  5. poj 2253 Frogger dijkstra算法实现

    点击打开链接 Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 21653   Accepted: 7042 D ...

  6. poj 2253 Frogger (最短路变种,连通图的最长边)

    题目 这里的dijsktra的变种代码是我看着自己打的,终于把代码和做法思路联系上了,也就是理解了算法——看来手跟着画一遍真的有助于理解. #define _CRT_SECURE_NO_WARNING ...

  7. 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 ...

  8. POJ 2253 Frogger(最短路&Floyd)题解

    题意:想给你公青蛙位置,再给你母青蛙位置,然后给你剩余位置,问你怎么走,公青蛙全力跳的的最远距离最小. 思路:这里不是求最短路径,而是要你找一条路,青蛙走这条路时,对他跳远要求最低.这个思想还是挺好迁 ...

  9. POJ. 2253 Frogger (Dijkstra )

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

随机推荐

  1. asp.net 怎么上传文件夹啊,不传压缩包!

    ASP.NET上传文件用FileUpLoad就可以,但是对文件夹的操作却不能用FileUpLoad来实现. 下面这个示例便是使用ASP.NET来实现上传文件夹并对文件夹进行压缩以及解压. ASP.NE ...

  2. 利用pdfbox和poi抽取pdf、doc以及docx格式的内容

    使用pdfbox1.5.0抽取pdf格式文档内容,使用poi3.7抽取doc及docx文档内容: /** * Created by yan.shi on 2017/9/25. */ import or ...

  3. 'vue' 不是内部或外部命令,也不是可运行的程序 或批处理文件

    解决方案:找到npm i xxx -g 下载后存放的路径,将路径添加到环境变量中,即可.1.npm config list 查看一下npm 的配置信息 2.打开路径看看里面的命令.window用户wi ...

  4. Mysql 执行安装脚本报错Changed limits:

    安装Mysql软件的时候报错,如下: [root@db bin]# ./mysql_install_db --basedir=/usr/local/mysql --datadir=/u01/app/m ...

  5. Unity3D_(网格导航)简单物体自动寻路

    NavMesh(导航网络)是3D游戏世界中用于实现动态物体自动寻路的一种技术,它将游戏场景中复杂的结构组织关系简化为带有一定信息的网格,进而在这些网格的基础上通过一系列的计算来实现自动寻路. 实现Ca ...

  6. cgo

    package main import ( "unsafe" "fmt") /*#cgo CFLAGS: -I./#cgo LDFLAGS: -L./#incl ...

  7. 第五次实验报告&学习总结

    一.实验目的 (1) 理解抽象类与接口的使用; (2)了 解包的作用,掌握包的设计方法. 二.实验要求 (1)掌 握使用抽象类的方法. (2)掌 握使用系统接口的技术和创建自定义接口的方法. (3) ...

  8. LeetCode 152. 乘积最大子序列(Maximum Product Subarray)

    题目描述 给定一个整数数组 nums ,找出一个序列中乘积最大的连续子序列(该序列至少包含一个数). 示例 1: 输入: [2,3,-2,4] 输出: 6 解释: 子数组 [2,3] 有最大乘积 6. ...

  9. Unknown class xxx in Interface Builder file. / NSUnknownKeyException

    Error: 2019-11-24 22:16:01.047997+0800 SingleViewDemo[22576:34699748] Unknown class FeedbackCell in ...

  10. [论文理解] Attentional Pooling for Action Recognition

    Attentional Pooling for Action Recognition 简介 这是一篇NIPS的文章,文章亮点是对池化进行矩阵表示,使用二阶池的矩阵表示,并将权重矩阵进行低秩分解,从而使 ...