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. 如何获取path与basePath

    <%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding=& ...

  2. java中怎么解决路径中文的问题

    在我遇到精灵线程的问题时,遇到一个中文路径的问题 原来是这样的 URL url=Test8.class.getClassLoader().getResource(""); Stri ...

  3. 【dp 背包变形】 poj 1837

    #include <cstdio> #include <memory.h> #include<iostream> using namespace std; ][]; ...

  4. hdu1950 Bridging signals 最长递增子序列

    用一个数组记下递增子序列长度为i时最小的len[i],不断更新len数组,最大的i即为最长递增子序列的长度 #include<cstdio> #include<algorithm&g ...

  5. HALF<水题>

    题意: 找出n/d=0.5的所有数.输入:test,x(代表n的位数,1<=x<=4).并且n和d的每一个位数不能有重复,也不能是0. 输入: 1 1 输出: the form 1/2 = ...

  6. 命令行调试smali

    am start -D -n com.agilebits.onepassword/.activity.LoginActivity ps | grep passu0_a126 1107 217 5107 ...

  7. JS的className,字体放大缩小

    <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...

  8. codeforces 558/C Amr and Chemistry(数论+位运算)

    题目链接:http://codeforces.com/problemset/problem/558/C 题意:把n个数变成相同所需要走的最小的步数易得到结论,两个奇数不同,一直×2不可能有重叠枚举每个 ...

  9. MapReduce入门例子

    计算文档中不同单词的个数. hello you hello me 步骤如下:

  10. 剑指offer 重建二叉树

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3 ...