<题目链接>

题目大意:

给出青蛙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】的更多相关文章

  1. poj 2253 Frogger 最小瓶颈路(变形的最小生成树 prim算法解决(需要很好的理解prim))

    传送门: http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissi ...

  2. POJ 2253 Frogger(最小最大距离)

    题意  给你n个点的坐标  求第1个点到第2个点的全部路径中两点间最大距离的最小值 非常水的floyd咯 #include<cstdio> #include<cmath> #i ...

  3. POJ - 2253 Frogger(最短路Dijkstra or flod)

    题意:要从起点的石头跳到终点的石头,设The frog distance为从起点到终点的某一路径中两点间距离的最大值,问在从起点到终点的所有路径中The frog distance的最小值为多少. 分 ...

  4. POJ. 2253 Frogger (Dijkstra )

    POJ. 2253 Frogger (Dijkstra ) 题意分析 首先给出n个点的坐标,其中第一个点的坐标为青蛙1的坐标,第二个点的坐标为青蛙2的坐标.给出的n个点,两两双向互通,求出由1到2可行 ...

  5. POJ 2253 Frogger(dijkstra 最短路

    POJ 2253 Frogger Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fion ...

  6. 最短路(Floyd_Warshall) POJ 2253 Frogger

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

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

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

  8. POJ 2253 ——Frogger——————【最短路、Dijkstra、最长边最小化】

    Frogger Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Stat ...

  9. poj 2253 Frogger (dijkstra最短路)

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

随机推荐

  1. jenkins配置sonarqube

    jenkins配置sonarqube 下载插件SonarQube Scanner for Jenkins 在系统管理系统设置中选择 SonarQube servers 配置服务器名称.访问URL地址, ...

  2. B - 低阶入门膜法 - D-query (查询区间内有多少不同的数)

    题目链接:https://cn.vjudge.net/contest/284294#problem/B 题目大意:查询区间内有多少个不相同的数. 具体思路:主席树的做法,主席树的基础做法是查询区间第k ...

  3. CentOS7配置网络

    #进入目录 cd /etc/sysconfig/network-scripts/ #编辑ifcfg-XXX vi ifcfg-eno167777 #把onboot=no 改为yes #重启 shutd ...

  4. WebRTC架构和协议栈-zz

    为了便于理解,我们来看一个最基本的三角形WebRTC架构(图4).在这个架构中,移动电话用“浏览器M”表示,笔记本电脑用“浏览器L”表示,通过Web服务器将它们连接起来.要建立一个实时媒体通讯,两台设 ...

  5. Latex graphicx 宏包 scalebox命令

    scalebox  命令需要加载  \usepackage{graphicx} \scalebox{水平缩放因子}[垂直缩放因子]{对象} \scalebox 命令对其作用的对象进行缩放,使缩放后的对 ...

  6. ubuntu14.04下 Kinect V2+Ros接口安装

    1. 首先git下载代码,放到主文件夹下面 git clone https://github.com/OpenKinect/libfreenect2.git 2. 然后安装依赖项如下,最好事先编译安装 ...

  7. python函数——形参中的:*args和**kwargs

    python函数——形参中的:*args和**kwargs   多个实参,放到一个元组里面,以*开头,可以传多个参数:**是形参中按照关键字传值把多余的传值以字典的方式呈现 *args:(表示的就是将 ...

  8. 利用capability特征加强Linux系统安全【转】

    转自:https://blog.csdn.net/fivedragon/article/details/676849 1.简介 UNIX是一种安全操作系统,它给普通用户尽可能低的权限,而把全部的系统权 ...

  9. 修改tomcat的server.xml配置web项目

    <!-- VideoWeb:自己编写的web项目名 path:表示当输入访问项目.. 如果path="" URL=localhost:8080就可以访问项目了 如果path= ...

  10. 560. Subarray Sum Equals K

    Given an array of integers and an integer k, you need to find the total number of continuous subarra ...