<题目链接>

题目大意:

给出青蛙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. Error: Cannot find module PhantomJS

    node install.js Considering PhantomJS found at /usr/local/bin/phantomjs Looks like an `npm install - ...

  2. Shiro+Spring+SpringMVC+Mybatis整合

    Demo源码地址,v1.0分支 https://github.com/jxjy/hr

  3. layer弹出层的iframe页面回调

    $("#ChoiceBank").click(function () { var width = $("#content").css("Width&q ...

  4. Django开发笔记三

    Django开发笔记一 Django开发笔记二 Django开发笔记三 Django开发笔记四 Django开发笔记五 Django开发笔记六 1.基于类的方式重写登录:views.py: from ...

  5. java中网络设置代理

    三种方式: 1.JVM启动时加参数设置代理 在系统启动时,使用-D项来设置代理. 例如: java -Dhttp.ProxyHost="proxyUrl" -Dhttp.Proxy ...

  6. python获取当前环境的编码

    # coding:gbk import sys import locale def p(f): print '%s.%s(): %s' % (f.__module__, f.__name__, f() ...

  7. myeclipse的web项目导入到eclipse中

    环境组成: java8 eclipse4.4.2 for javaee tomcat 7.0.61 1.导入myeclipse项目 2.设置JDK环境 3.将导入的项目修改为web项目 将myecli ...

  8. Android通讯:短信

    Android通讯之短信功能实现: 使用android.telephony.SmsManager对象,可以发送短信和彩信.// 构造回调函数,短信发送结束后,会发出对应的Intent请求Intent ...

  9. PYTHON-基本数据类型-数字类型,字符串类型,列表类型-练习

    # 字符串练习# 写代码,有如下变量,请按照要求实现每个功能 (共6分,每小题各0.5分)# name = " aleX"# # 1) 移除 name 变量对应的值两边的空格,并输 ...

  10. 100以内的质数(for和if)