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. java设计模式案例详解:观察者模式

    观察者模式的应用场景: 1. 对一个对象状态的更新,需要其他对象同步更新,而且其他对象的数量动态可变. 2. 对象仅需要将自己的更新通知给其他对象而不需要知道其他对象的细节. 举个例子说明,这个例子讲 ...

  2. UVA 11992 线段树

    input r c m      r<=20,1<=m<=20000 m行操作 1 x1 y1 x2 y2 v       add v 2 x1 y1 x2 y2 v       s ...

  3. AFHTTPSessionManager

    // 取消所有请求 [self.manager.tasks makeObjectsPerformSelector:@selector(cancel)]; 使用场景: 比如一个界面有下拉刷新和上拉加载两 ...

  4. HttpSession详解

    HttpSession详解   session的机制 http是无状态的协议,客户每次读取web页面时,服务器都打开新的会话,而且服务器也不会自动维护客户的上下文信息,那么要怎么才能实现会话跟踪呢?s ...

  5. USB鼠标线序

    鼠标线断了,找了个废弃的手机充电线接上,特记录线序如下: 红————白          白————橙绿————绿黑————蓝

  6. java 实例方法和类方法的区别

  7. JavaScript算法与数据结构知识点记录

    JavaScript算法与数据结构知识点记录 zhanweifu

  8. hdu_5589_Tree(莫队+字典树)

    题目连接:hdu_5589_Tree 题意:给你一棵树和一些边值,n个点n-1条边,一个m,q个询问,每个询问让你输出在[l,r]区间内任意两点树上的路径的边权异或的和大于m的点对数. 题解:这题很巧 ...

  9. 低电压锁定(UVLO) (转)

    源:http://blog.csdn.net/zhenwenxian/article/details/8523307 UVLO就是低电压锁定: 低压关断. 欠压关断模式是当供电电压低于IC的开启门限电 ...

  10. 清除浮动的方法 after伪类。

    .clearfix{ *zoom:1; } .clearfix:after{ content: ""; display: block; clear: both; } 在样式中加入上 ...