题目链接:http://poj.org/problem?id=2253

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 (<=n<=). The next n lines each contain two integers xi,yi ( <= xi,yi <= ) representing the coordinates of stone #i. Stone # is Freddy's stone, stone #2 is Fiona's stone, the other n- 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 ) 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 Sample Output Scenario #
Frog Distance = 5.000 Scenario #
Frog Distance = 1.414 Source
Ulm Local

题目大意:有一只青蛙想到另一只青蛙那,但是不能一次到位,他需要借助中间的石头跳跃,问他到另一只那走的最短路中的最长跳跃距离是多少?

方法:求到另一只青蛙的地方的最小生成树的最大距离。

 #include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<math.h>
#include<queue>
using namespace std;
#define INF 0x3f3f3f3f
#define ll long long
#define met(a,b) memset(a,b,sizeof(a))
#define N 500
struct node
{
int x,y; }s[N];
int Map[N][N];
int dis[N],ans;
int vis[N];
void dij(int n)
{
met(vis,);
for(int i=;i<=n;i++)
dis[i]=Map[][i];
vis[]=;
for(int i=;i<n;i++)
{
int an=INF;
int k=-;
for(int j=;j<=n;j++)
{
if(!vis[j] && an>dis[j])
an=dis[k=j];
}
ans=max(ans,an);
if(k==)///当k==2已经到达另一只青蛙的坐标
return ;
vis[k]=;
for(int j=;j<=n;j++)
{
if(!vis[j])
dis[j]=min(dis[j],Map[k][j]);
} }
}
int main()
{
int n;
int con=;
while(scanf("%d",&n),n)
{
for(int i=;i<=n;i++)
{
for(int j=;j<=n;j++)
Map[i][j]=i==j?:INF;
}
for(int i=;i<=n;i++)
{
scanf("%d %d",&s[i].x,&s[i].y);
}
for(int i=;i<=n;i++)
{
for(int j=i;j<=n;j++)
{
int ans=(s[i].x-s[j].x)*(s[i].x-s[j].x)+(s[i].y-s[j].y)*(s[i].y-s[j].y);
Map[i][j]=Map[j][i]=ans;
}
}
ans=-INF;
dij(n);
printf("Scenario #%d\n",con++);
printf("Frog Distance = %.3f\n\n",sqrt(ans));
}
return ;
}

(poj 2253) Frogger 最短路上的最大路段的更多相关文章

  1. 最短路(Floyd_Warshall) POJ 2253 Frogger

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

  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. POJ 2253 Frogger(dijkstra 最短路

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

  5. poj 2253 Frogger 最小瓶颈路(变形的最小生成树 prim算法解决(需要很好的理解prim))

    传送门: http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissi ...

  6. POJ 2253 Frogger

    题目链接:http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissi ...

  7. poj 2253 Frogger (dijkstra最短路)

    题目链接:http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissi ...

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

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

  9. POJ 2253 Frogger Floyd

    原题链接:http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissi ...

随机推荐

  1. HttpHandler实现网页图片防盗链

    using System; using System.Collections.Generic; using System.Linq; using System.Web; /// <summary ...

  2. 一、Selenium 工作原理

    1.Selenium介绍 Selenium是用于测试Web应用程序用户界面UI的常用框架.端对端的功能测试.并且在一个多个浏览器中操作. 目前Seienium 组件主要包括Selenium IDE   ...

  3. 在Django中接收文件并存储

    首先是一个views函数的例子 def get_user_profiles(request): if request.method == 'POST': myFile = request.FILES. ...

  4. LeetCode算法题-Binary Watch(Java实现)

    这是悦乐书的第216次更新,第229篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第84题(顺位题号是401).二进制手表顶部有4个LED,代表小时(0-11),底部的6 ...

  5. Linux 小知识翻译 - 「邮件服务器」

    这次聊聊「邮件服务器」. 邮件服务器上通常会运行2个服务端软件,「SMTP服务器」和「POP服务器或者IMAP服务器」. 这2个东西,也许使用邮件客户端的人立马就明白了.因为设置邮件客户端的时候,需要 ...

  6. C语言 排序算法总结

    #include<stdio.h> #include<stdlib.h> //作者:凯鲁嘎吉 - 博客园 http://www.cnblogs.com/kailugaji/ # ...

  7. syslog的坑

    先看看代码: g_log, err := syslog.NewLogger(syslog.LOG_INFO, ) 再看看syslog的源码: // NewLogger creates a log.Lo ...

  8. 移动端rem flexible方案

    一.px 自动转换为rem sublim Text3 下载本项目,比如:git clone https://github.com/flashlizi/cssrem 进入packages目录(在Subl ...

  9. C. Playlist Educational Codeforces Round 62 (Rated for Div. 2) 贪心+优先队列

    C. Playlist time limit per test 2 seconds memory limit per test 256 megabytes input standard input o ...

  10. 使用chrome远程调试设备及调试模拟器设备

    使用chrome开发工具远程在Android上远程调试 准备工作 开始远程调试之前,需要做好如下准备: 在你电脑上安装Chrome 32 或者更新的版本 一根连接Android设备的USB线 手机系统 ...