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.

  题目就是求所有通路中,最大边权最小的那一条。。。。。。

  应用Dijkstra的思想,一个个的标记。。。

代码如下:

#include<iostream>
#include<cstring>
#include<cmath> #define max(a,b) (a>b ? a:b) using namespace std; const int INF=10e8; int N;
int X[],Y[];
double ans[];
bool vis[]; void Dijkstra()
{
int k;
double minn,len; for(int i=;i<=N;++i)
{
vis[i]=;
ans[i]=INF;
}
ans[]=; for(int i=;i<=N;++i)
{
k=-;
minn=INF; for(int j=;j<=N;++j)
if(!vis[j] && ans[j]<minn)
{
minn=ans[j];
k=j;
} if(k==-)
break; vis[k]=; for(int j=;j<=N;++j)
{
len=sqrt((double(X[k])-X[j])*(X[k]-X[j])+(double(Y[k])-Y[j])*(Y[k]-Y[j])); if(!vis[j] && max(len,ans[k])<ans[j])
ans[j]=max(len,ans[k]);
}
}
} int main()
{
ios::sync_with_stdio(false);
cout.setf(ios::fixed);
cout.precision(); int cas=; for(cin>>N;N;cin>>N,++cas)
{
for(int i=;i<=N;++i)
cin>>X[i]>>Y[i]; Dijkstra(); cout<<"Scenario #"<<cas<<endl;
cout<<"Frog Distance = "<<ans[]<<endl<<endl;
} return ;
}

(简单) POJ 2253 Frogger,Dijkstra。的更多相关文章

  1. poj 2253 Frogger dijkstra算法实现

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

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

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

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

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

  6. POJ 2253 Frogger ,poj3660Cow Contest(判断绝对顺序)(最短路,floyed)

    POJ 2253 Frogger题目意思就是求所有路径中最大路径中的最小值. #include<iostream> #include<cstdio> #include<s ...

  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

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

随机推荐

  1. 转 如何不耍流氓的做运维之——SHELL脚本

    家都是文明人,尤其是做运维的,那叫一个斯文啊.怎么能耍流氓呢?赶紧看看,编写 SHELL 脚本如何能够不耍流氓. 下面的案例,我们以 MySQL 数据库备份 SHELL 脚本的案例来进行阐述. 不记录 ...

  2. IDL和生成代码分析

    IDL:接口描述语言 这里使用thrift-0.8.0-xsb这个版本来介绍IDL的定义以及简单实例分析. 1. namespace 定义包名 2.struct 结构体,定义服务接口的参数和返回值用到 ...

  3. 会话管理---Cookie与Session

    会话可简单理解为:用户开一个浏览器,点击多个超链接,访问服务器多个web资源,然后关闭浏览器,整个过程称之为一个会话. 保存会话数据的两种技术:Cookie,Session Cookie是客户端技术, ...

  4. SqlServer 查询死锁,杀死死锁进程

    -- 查询死锁 select request_session_id spid, OBJECT_NAME(resource_associated_entity_id) tableName from sy ...

  5. druid-1.0.13 数据库配置文件密码加密

    1.cmd 切换到druid目录  我的是C:\tool\apache-tomcat-7.0.67\webapps\projectA\WEB-INF\lib 2.运行命令 java -cp druid ...

  6. Nape 获取碰撞点加特效

    package { import nape.phys.Body; import nape.shape.Shape; import nape.shape.Circle; import flash.dis ...

  7. CentOS下将自编译的Apache添加为系统服务

    首先,先谈下对linux服务的理解 1,linux 服务运行方式: 脚本的方式运行,服务脚本存放位置/etc/rc.d/init.d/ 2,linux服务管理软件 chkconfig Red Hat公 ...

  8. 逆序一个8bit的2进制数

  9. 6-SUPER关键字

    (1)强行调用父类方法的执行(2)super不一定在重写中使用,也可以表示那些方法是从父类中继承而来的.

  10. angular实现select的ng-options4

    ng实现简单的select <div ng-controller="ngSelect"> <select ng-model="vm.selectVal& ...