<题目链接>

题目大意:

给出青蛙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. B. Light It Up

    题目链接:http://codeforces.com/problemset/problem/1000/B 代码: #include<iostream> #include<cstrin ...

  2. SVN备份还原

    本文是对SVN备份还原的一个简单记录 /*千万不能用VisualSVN Server PowerShell,否则在还原Load的时候会发生错误E140001,具体参考http://stackoverf ...

  3. cartographer 安装问题

    安装主要参考hitcm教程: http://www.cnblogs.com/hitcm/p/5939507.html 这里只说安装过程中遇到的问题, ceres-solver 与 eigen3 版本不 ...

  4. SpringMVC跨重定向请求传递数据

    (1)使用URL模板以路径变量和查询参数的形式传递数据(一些简单的数据) @GetMapping("/home/index") public String index(Model ...

  5. arm-linux-gcc/ld/objcopy/objdump参数总结【转】

    arm-linux-gcc/ld/objcopy/objdump参数总结 转自:http://blog.csdn.net/muyuyuzhong/article/details/7755291 arm ...

  6. A1pass大大对黑客学习的建议

    本文转自:http://bbs.hackav.com/thread-92-1-1.html 菜鸟不可怕,可怕的是你认为自己一辈子都是菜鸟.每个高手都是从菜鸟进化过来的,就算是现在黑客界的泰斗们当年也无 ...

  7. saltstack文件模块的replace操作简化

    代码已经过测试 import re import mmap import os import shutil old_text='test' new_text='text' path=r'C:\User ...

  8. Spring事务回滚和异常类

    1.异常的一些基本知识 异常的架构 异常的继承结构:Throwable为基类,Error和Exception继承Throwable.Error和RuntimeException及其子类成为未检查异常( ...

  9. PYTHON-函数的定义与调用,返回值,和参数-练习

    # day10函数的定义调用和参数作业# 1.写函数,用户传入修改的文件名.与要修改的内容,执行函数,完成批量修改操作# def modify_file(filename,old,new):# imp ...

  10. OCM_第十三天课程:Section6 —》数据库性能调优 _结果缓存 /多列数据信息采集统计/采集数据信息保持游标有效

    注:本文为原著(其内容来自 腾科教育培训课堂).阅读本文注意事项如下: 1:所有文章的转载请标注本文出处. 2:本文非本人不得用于商业用途.违者将承当相应法律责任. 3:该系列文章目录列表: 一:&l ...