poj 2253 Frogger (最小最大路段)【dijkstra】
<题目链接>
题目大意:
给出青蛙A,B和若干石头的坐标,现青蛙A想到青蛙B那,A可通过任意石头到达B,问从A到B多条路径中最小的最长边。
解题分析:
这是最短路的一类典型题目,与普通的最短路的不同之处在于松弛操作。
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std; #define N 205
int n;
struct Node{
int x,y;
Node(int _x=,int _y=):x(_x),y(_y){}
}node[N];
bool vis[N];
double dist[N];
double dis(Node a,Node b){
return (double)sqrt(1.0*(a.x-b.x)*(a.x-b.x)+1.0*(a.y-b.y)*(a.y-b.y));
}
void Dij(){
memset(vis,,sizeof(vis));
for(int i=;i<=n;i++)dist[i]=dis(node[],node[i]);
for(int i=;i<=n;i++){
int cur;double mn=1e9;
for(int j=;j<=n;j++){
if(!vis[j] && dist[j]<mn)
mn=dist[j],cur=j;
}
vis[cur]=;
for(int j=;j<=n;j++){
if(!vis[j] && dist[j]>max(dist[cur],dis(node[cur],node[j]))){ //得到最小的最大路段值
dist[j]=max(dist[cur],dis(node[cur],node[j]));
}
}
}
}
int main(){
int ncase=;
while(scanf("%d",&n)!=EOF,n){
for(int i=;i<=n;i++){
int u,v;scanf("%d%d",&u,&v);
node[i]=Node(u,v);
}
Dij();
printf("Scenario #%d\n",++ncase);
printf("Frog Distance = %.3lf\n\n",dist[]);
}
}
2018-08-26
poj 2253 Frogger (最小最大路段)【dijkstra】的更多相关文章
- poj 2253 Frogger 最小瓶颈路(变形的最小生成树 prim算法解决(需要很好的理解prim))
传送门: http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS Memory Limit: 65536K Total Submissi ...
- POJ 2253 Frogger(最小最大距离)
题意 给你n个点的坐标 求第1个点到第2个点的全部路径中两点间最大距离的最小值 非常水的floyd咯 #include<cstdio> #include<cmath> #i ...
- POJ - 2253 Frogger(最短路Dijkstra or flod)
题意:要从起点的石头跳到终点的石头,设The frog distance为从起点到终点的某一路径中两点间距离的最大值,问在从起点到终点的所有路径中The frog distance的最小值为多少. 分 ...
- 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、最长边最小化】
Frogger Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Stat ...
- poj 2253 Frogger (dijkstra最短路)
题目链接:http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS Memory Limit: 65536K Total Submissi ...
随机推荐
- keepalived高可用系列~通用基础
简介:今天咱们来聊聊keepalived一 keepalived 架构 1 标准架构: keepalived+lvs/haproxy+后端 real server(mysql从库,nginx.myc ...
- Ubuntu 14.04 apt-get更换阿里云源
https://blog.csdn.net/satomic/article/details/78997611
- latex 字体大小设置
tex 设置字体大小命令由小到大依次为: \tiny \scriptsize \footnotesize \small \normalsize \large \Large \LARGE \huge \ ...
- ORB feature(O for orientation)
参考链接:http://blog.csdn.net/yang843061497/article/details/38553765 绪论 假如我有2张美女图片,我想确认这2张图片中美女是否是同一个人.这 ...
- MySQL基于LVM快照的备份恢复(临时)
目录1.数据库全备份2.准备LVM卷3.数据恢复到LVM卷4.基于LVM快照备份数据5.数据灾难恢复6.总结 写在前面:测试环境中已安装有mysql 5.5.36数据库,但数据目录没有存放在LVM卷, ...
- python高级编程读书笔记(一)
python高级编程读书笔记(一) python 高级编程读书笔记,记录一下基础和高级用法 python2和python3兼容处理 使用sys模块使程序python2和python3兼容 import ...
- phantomjs 截取twitter的网页(动态生成的页面)
// This example shows how to render pages that perform AJAX calls// upon page load.//// Instead of w ...
- Bootstrap3.0学习第二轮(栅格系统原理)
详情请查看 http://aehyok.com/Blog/Detail/8.html 个人网站地址:aehyok.com QQ 技术群号:206058845,验证码为:aehyok 本文文章链接:ht ...
- C#实现图片叠加,图片上嵌入文字,文字生成图片的方法
/// <summary> /// 图片叠加 /// </summary> /// <param name="sender"& ...
- Git学习笔记一《版本控制之道-使用Git》
1.在Windows中安装完git后,需要进行一下配置:$ git config --global user.name "zhangliang"$ git config --glo ...