题目链接: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. SQL server 获得 表的主键,自增键

    主键: @tableName --表名 @id ---表对应的id SELECT SYSCOLUMNS.name FROM SYSCOLUMNS,SYSOBJECTS,SYSINDEXES,SYSIN ...

  2. 转:敏捷开发之Scrum扫盲篇

    现在敏捷开发是越来越火了,人人都在谈敏捷,人人都在学习Scrum和XP... 为了不落后他人,于是我也开始学习Scrum,今天主要是对我最近阅读的相关资料,根据自己的理解,用自己的话来讲述Scrum中 ...

  3. Python中函数partial的应用

    函数在执行时,要带上所有必要的参数进行调用.但是,有时参数可以在函数被调用之前提前获知.这种情况下, 一个函数有一个或多个参数预先就能用上,以便函数能用更少的参数进行调用.通过设定参数的默认值,可以降 ...

  4. 学习flying logic

    之前在知乎上结识的朋友吴笛,他的qq空间里分享了  flying logic的一些用途,我想到可以规划和团队的目标,这点让我感到很兴奋,分享学习这个软件. 学习之前,我应当把软件中的单词学明白.现在就 ...

  5. jQuery -- 光阴似箭(五):AJAX 方法

    jQuery -- 知识点回顾篇(五):AJAX 方法 1. $.ajax 方法:用于执行 AJAX(异步 HTTP)请求. <!DOCTYPE html> <html> &l ...

  6. LeetCode算法题-Valid Anagram(Java实现)

    这是悦乐书的第198次更新,第205篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第61题(顺位题号是242).给定两个字符串s和t,写一个函数来确定t是否是s的anag ...

  7. C3P0连接池温习1

    一.应用程序直接获取数据库连接的缺点 用户每次请求都需要向数据库获得链接,而数据库创建连接通常需要消耗相对较大的资源,创建时间也较长.假设网站一天10万访问量,数据库服务器就需要创建10万次连接,极大 ...

  8. Java 7 for Absolute Beginners/Java 7基础教程--读后感

    1. 很适合部分初学者,因为书中对于JAVA许多特性都有涉猎,而且也是浅尝即止.如果读者没有受过专业的编程训练,那么在阅读此书时不会畏惧.因为书中没有充斥着大量的计算机理论知识,虽然作者依然覆盖了JA ...

  9. 如何在tomcat前部署一个nginx

    在tomcat应用已经发布后,如何在tomcat前部署一个nginx,可以正常访问jsp,静态资源(html,css,js) 这里tomcat的端口号是8888 upstream morris { s ...

  10. LightGBM介绍及参数调优

    1.LightGBM简介 LightGBM是一个梯度Boosting框架,使用基于决策树的学习算法.它可以说是分布式的,高效的,有以下优势: 1)更快的训练效率 2)低内存使用 3)更高的准确率 4) ...