题目链接:https://vjudge.net/problem/POJ-2253

题意:给出n个点的坐标,求点1到点2的forg distance,其定义为点1到点2的所有路径中最长边的最小值。

思路:floyd真的很强大,改一下定义,dis[i][j]表示i到j的frog distance,然后枚举中间点k,转移方程是dis[i][j]=min(dis[i][j],max(dis[i][k],dis[k][j]))。复杂度O(n^3).

AC代码:

e<cstdio>
#include<cmath>
#include<algorithm>
using namespace std; typedef pair<int,int> PII;
const int maxn=;
PII p[maxn];
int n,cas;
double dis[maxn][maxn]; double getdis(PII p1,PII p2){
return sqrt((p1.first-p2.first)*(p1.first-p2.first)*1.0+
(p1.second-p2.second)*(p1.second-p2.second)*1.0);
} int main(){
while(scanf("%d",&n),n){
for(int i=;i<=n;++i){
int x,y;
scanf("%d%d",&x,&y);
p[i]=make_pair(x,y);
}
for(int i=;i<=n;++i){
dis[i][i]=0.0;
for(int j=i+;j<=n;++j)
dis[i][j]=dis[j][i]=getdis(p[i],p[j]);
}
for(int k=;k<=n;++k)
for(int i=;i<=n;++i)
for(int j=;j<=n;++j)
dis[i][j]=min(dis[i][j],max(dis[i][k],dis[k][j]));
printf("Scenario #%d\n",++cas);
printf("Frog Distance = %.3f\n\n",dis[][]);
}
return ;
}

poj2253(floyd变形)的更多相关文章

  1. POJ2253——Frogger(Floyd变形)

    Frogger DescriptionFreddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fi ...

  2. UVA10048 Audiophobia[Floyd变形]

    UVA - 10048 Audiophobia Consider yourself lucky! Consider yourself lucky to be still breathing and h ...

  3. hdu 1596(Floyd 变形)

    http://acm.hdu.edu.cn/showproblem.php?pid=1596 find the safest road Time Limit: 10000/5000 MS (Java/ ...

  4. hdu 1217 (Floyd变形)

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=1217 Arbitrage Time Limit: 2000/1000 MS (Java/Others)   ...

  5. Frogger(floyd变形)

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

  6. UVa 10048 (Floyd变形) Audiophobia

    题意: 给一个带权无向图,和一些询问,每次询问两个点之间最大权的最小路径. 分析: 紫书上的题解是错误的,应该是把原算法中的加号变成max即可.但推理过程还是类似的,如果理解了Floyd算法的话,这个 ...

  7. find the mincost route(floyd变形 无向图最小环)

    Time Limit: 1000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission( ...

  8. hdu1569find the safest road(floyd变形求最大安全值)

    find the safest road Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  9. zoj3710 friends(floyd变形)

    Friends Time Limit: 2 Seconds      Memory Limit: 65536 KB Alice lives in the country where people li ...

随机推荐

  1. vue中setInterval的清除

    两种清除setInterval的方式: 方案一: data() { return { timer: null // 定时器名称 } }, mouted() { this.timer = (() =&g ...

  2. 提高RabbitMQ的File descriptors

    一.修改 linux ulimit 二. [root@rabbitmq rabbitmq]# ulimit -n 65535 [root@rabbitmq rabbitmq]# ulimit -n 6 ...

  3. BZOJ 4734 UOJ #269 如何优雅地求和 (多项式)

    题目链接 (BZOJ) https://www.lydsy.com/JudgeOnline/problem.php?id=4734 (UOJ) http://uoj.ac/problem/269 题解 ...

  4. vue后台_实战篇

    一.一些常用组件效果的实现 1)面包屑导航 主要是使用$route.mathed:一个数组,包含当前路由的所有嵌套路径片段的路由记录 .路由记录就是 routes 配置数组中的对象副本 (还有在 ch ...

  5. 了解Spring Boot的自动配置

    摘自:https://www.jianshu.com/p/ddb6e32e3faf Spring Boot的自动配置给开发者带来了很大的便利,当开发人员在pom文件中添加starter依赖后,mave ...

  6. go区分操作系统

    package main import ( "fmt" "runtime" ) func main() { fmt.Println("Go runs ...

  7. php mvc 模式的开发注意事项

    1.控制器中: 如果不涉及到数据库的就在控制器中. empty($res['code']) ? $this->error($res['msg']) : $this->success($re ...

  8. 获得数据源和路径desc.catalogPath

    workspace:C:\Users\dell\Documents\ArcGIS\Default.gdb\ddf inPath:c:\users\dell\documents\arcgis\defau ...

  9. ios UISegmentedControl 用法举例

    UISegmentedControl * segmentControl = [[UISegmentedControl alloc]initWithFrame:CGRectMake(0, 0, 160, ...

  10. Java同步数据结构之DelayQueue/DelayedWorkQueue

    前言 前面介绍了优先级队列PriorityBlockingQueue,顺带也说了一下PriorityQueue,两者的实现方式是一模一样的,都是采用基于数组的平衡二叉堆实现,不论入队的顺序怎么样,ta ...