Frogger(floyd变形)
Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u
Description
Unfortunately Fiona's stone is out of his jump range. Therefore Freddy considers to use other stones as intermediate stops and reach her by a sequence of several small jumps.
To execute a given sequence of jumps, a frog's jump range obviously must be at least as long as the longest jump occuring in the sequence.
The frog distance (humans also call it minimax distance) between two stones therefore is defined as the minimum necessary jump range over all possible paths between the two stones.
You are given the coordinates of Freddy's stone, Fiona's stone and all other stones in the lake. Your job is to compute the frog distance between Freddy's and Fiona's stone.
Input
Output
The frog distance (humans also call it minimax distance) between two stones therefore is defined as the minimum necessary jump range over all possible paths between the two stones.
#include <iostream>
#include <algorithm>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath> using namespace std; const int sz = ;
const double inf = 10.0e8;
double d[sz][sz], x[sz], y[sz];
int n; void get_dist(int i, int j)
{
d[i][j] = d[j][i] = sqrt((x[i] - x[j]) * (x[i] - x[j]) +
(y[i] - y[j]) * (y[i] - y[j]));
} void floyd()
{
for(int k = ; k <= n; k++){
for(int i = ; i <= n; i++){
for(int j = ; j <= n; j++){
d[i][j] = min(d[i][j], max(d[i][k], d[k][j]));
}
}
}
} int main()
{
int ca = ;
while(scanf("%d", &n) && n){
for(int i = ; i <= n; i++){
for(int j = ; j <= n; j++){
d[i][j] = inf;
}
d[i][i] = 0.0;
}
for(int i = ; i <= n; i++){
scanf("%lf %lf", x + i, y + i);
for(int j = i - ; j > ; j--){
get_dist(i, j);
}
}
floyd();
printf("Scenario #%d\nFrog Distance = %.3lf\n\n", ca++, d[][]);
}
return ;
}
Frogger(floyd变形)的更多相关文章
- POJ2253——Frogger(Floyd变形)
Frogger DescriptionFreddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fi ...
- UVA10048 Audiophobia[Floyd变形]
UVA - 10048 Audiophobia Consider yourself lucky! Consider yourself lucky to be still breathing and h ...
- poj 2253 Frogger(floyd变形)
题目链接:http://poj.org/problem?id=1797 题意:给出两只青蛙的坐标A.B,和其他的n-2个坐标,任一两个坐标点间都是双向连通的.显然从A到B存在至少一条的通路,每一条通路 ...
- hdu 1596(Floyd 变形)
http://acm.hdu.edu.cn/showproblem.php?pid=1596 find the safest road Time Limit: 10000/5000 MS (Java/ ...
- hdu 1217 (Floyd变形)
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1217 Arbitrage Time Limit: 2000/1000 MS (Java/Others) ...
- poj2253 Frogger(Floyd)
题目链接 http://poj.org/problem?id=2253 题意 给出青蛙A,B和若干石头的坐标,现在青蛙A要跳到青蛙B所在的石头上,求出所有路径中最远那一跳的最小值. 思路 Floyd算 ...
- POJ 2253 Frogger Floyd
原题链接:http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS Memory Limit: 65536K Total Submissi ...
- UVa 10048 (Floyd变形) Audiophobia
题意: 给一个带权无向图,和一些询问,每次询问两个点之间最大权的最小路径. 分析: 紫书上的题解是错误的,应该是把原算法中的加号变成max即可.但推理过程还是类似的,如果理解了Floyd算法的话,这个 ...
- find the mincost route(floyd变形 无向图最小环)
Time Limit: 1000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission( ...
随机推荐
- spring三种实例化bean的方式
1构造函数实例化 2静态工厂方法实例化 3实例工厂方法实例化 service接口: package service; public interface PersonService { public v ...
- iOS YSAuth 第三方登录及分享
概述 在很多时候,我们使用的都是第三方插件来处理登录与分享,比如使用友盟.但要是我们需要自己写一套自己的登录.分享.支付的时候,就可以使用YSAuth这个类库. github:https://gith ...
- 仿IOS 开关按钮
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- Leetcode 130 Surrounded Regions DFS
将内部的O点变成X input X X X XX O O X X X O XX O X X output X X X XX X X XX X X XX O X X DFS的基本框架是 void dfs ...
- 充分利用 UE4 中的噪声
转自:https://www.unrealengine.com/zh-CN/blog/getting-the-most-out-of-noise-in-ue4 UE4 推出基于材质的程序式噪声已经有一 ...
- Node + Express + Mysql的CMS小结
因为之前用过上述的组合完成过很多系统,而这一次是为了实现一个帮助系统的静态网页发布.因为很久不写,重点说遇到的几个坑: 1.库版本的问题 比如mysql连接数据库一直报错,因为系统重装过,所以重新安装 ...
- NAS服务器局域网内IPad、手机、电视盒子等联网播放
为把各个移动硬盘和不同电脑的数据进行统一管理,入手了一台希捷 Seagate Business 无内置硬盘 商业级 2盘位 云存储网路存储,经过卖家指点和不断摸索,终于能用了,主要步骤如下: 1. 系 ...
- CMD command
过滤字符串查找:netstat -aon|findstr "80"
- ubuntu 16.04 U盘多媒体不自动弹出
如下图: 设置 --> 详细信息 --> 可移动媒体 来自为知笔记(Wiz)
- MapReduce的一点理解
对于MapReduce编程,大概率的流程用过的人或多或少都清楚,但是归结到细节上,就有的地方不清楚了,下面根据自己的疑问,加上从网上各处,找到的被人的描述,最自己的疑问做出回答. 1. MapRedu ...