(简单) POJ 2253 Frogger,Dijkstra。
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。的更多相关文章
- poj 2253 Frogger dijkstra算法实现
点击打开链接 Frogger Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 21653 Accepted: 7042 D ...
- POJ 2253 - Frogger - [dijkstra求最短路]
Time Limit: 1000MS Memory Limit: 65536K Description Freddy Frog is sitting on a stone in the middle ...
- POJ. 2253 Frogger (Dijkstra )
POJ. 2253 Frogger (Dijkstra ) 题意分析 首先给出n个点的坐标,其中第一个点的坐标为青蛙1的坐标,第二个点的坐标为青蛙2的坐标.给出的n个点,两两双向互通,求出由1到2可行 ...
- POJ 2253 Frogger(dijkstra 最短路
POJ 2253 Frogger Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fion ...
- 最短路(Floyd_Warshall) POJ 2253 Frogger
题目传送门 /* 最短路:Floyd算法模板题 */ #include <cstdio> #include <iostream> #include <algorithm& ...
- POJ 2253 Frogger ,poj3660Cow Contest(判断绝对顺序)(最短路,floyed)
POJ 2253 Frogger题目意思就是求所有路径中最大路径中的最小值. #include<iostream> #include<cstdio> #include<s ...
- poj 2253 Frogger (dijkstra最短路)
题目链接:http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS Memory Limit: 65536K Total Submissi ...
- POJ 2253 ——Frogger——————【最短路、Dijkstra、最长边最小化】
Frogger Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Stat ...
- POJ 2253 Frogger
题目链接:http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS Memory Limit: 65536K Total Submissi ...
随机推荐
- 上海赛趣-top.mainFrame.tabAddHandler方法详解
top.mainFrame.tabAddHandler("item"+Id,'项目:'+itemname,'<%=basePath%>bizitem/goEditIte ...
- phpstudy 安装memcached服务和memcache扩展
memcached安装步骤: 首先,将下载好的memcahed解压到某个文件目录下,例如 C:\memcached 然后,在cmd里,输入"C:\memcached\memcached.ex ...
- linux视频学习4(crontab和进程)
1 . crontab定时任务: 任务调度: 系统在某个时间执行的特定的命令. 分类: 1.系统工作.2.个别的用户工作. 设置任务调度文件: /etc/crontab 1.crontab -e : ...
- THOUGHTS: programming in linux... with third_party open sources... methods
Actually I do not have experiences in programming with open sources/third party libs.. in linux.. I ...
- list遍历
一.对List的遍历有三种方式 List<String> list = new ArrayList<String>(); ...
- java包(package)
为了更好地组织类,java提供了包机制,用于区别类名的命名空间. 这样在不同的命名空间就可以有相同命名的类. 1 把功能相似或相关的类或接口阻止在同一个包中,方便类的查找和使用. 2 如同文件夹一样, ...
- Linux学习 -- 权限管理
1 ACL权限 1.1 简介与开启 1.1.1 ACL权限是什么 access control list 访问控制表 解决传统的(owner,group,others)身份不足的情况 可以设置 特定用 ...
- Swift学习(1)
swif(1) println("Hello, world") 输出结果: Hello, world swift使用let来声明常量,使用var来声明变量 //变量 var myV ...
- 笔记整理--Http-Cookie
如何设置一个永远无法删除的Cookie -- 系统架构 -- IT技术博客大学习 -- 共学习 共进步! - Google Chrome (2013/6/20 9:46:38) 如何设置一个永远无法删 ...
- javascript 手机号码正则表达式验证函数
代码如下: function checkMobile(){ var sMobile = document.mobileform.mobile.value if(!(/^1[3|4|5| ...