题意:想给你公青蛙位置,再给你母青蛙位置,然后给你剩余位置,问你怎么走,公青蛙全力跳的的最远距离最小。

思路:这里不是求最短路径,而是要你找一条路,青蛙走这条路时,对他跳远要求最低。这个思想还是挺好迁移的,原来我们用mp[i][j]表示i到j最短路径,那么我们现在用它表示i到j最大步伐,然后每次比较,只要最大步伐比他小,那么我们就走新的路。注意最后是mp[1][2],一直mp[1][n]没改无限WA。

代码;

#include<cstdio>
#include<set>
#include<cmath>
#include<stack>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int maxn = 200+5;
const int INF = 0x3f3f3f3f;
struct Node{
double x,y;
}node[maxn];
double mp[maxn][maxn]; //表示i->j的最大步伐
int Case = 1;
void Floyd(int n){
for(int k = 1;k <= n;k++){
for(int i = 1;i <= n;i++){
for(int j = 1;j <= n;j++){
if(mp[i][j] > max(mp[i][k],mp[k][j])){ //这样走最大步伐比较小
mp[i][j] = mp[j][i]= max(mp[i][k],mp[k][j]);
}
}
}
}
printf("Scenario #%d\nFrog Distance = %.3lf\n\n",Case++,mp[1][2]);
}
int main(){
int n,m;
while(~scanf("%d",&n) && n){
for(int i = 1;i <= n;i++)
scanf("%lf%lf",&node[i].x,&node[i].y);
for(int i = 1;i <= n;i++){
for(int j = i + 1;j <= n;j++){
mp[i][j] = mp[j][i] = sqrt((node[i].x - node[j].x)*(node[i].x - node[j].x) +
(node[i].y - node[j].y)*(node[i].y - node[j].y));
}
}
Floyd(n);
}
return 0;
}

POJ 2253 Frogger(最短路&Floyd)题解的更多相关文章

  1. poj 2253 Frogger(最短路 floyd)

    题目:http://poj.org/problem?id=2253 题意:给出两只青蛙的坐标A.B,和其他的n-2个坐标,任一两个坐标点间都是双向连通的.显然从A到B存在至少一条的通路,每一条通路的元 ...

  2. POJ 2253 Frogger 最短路 难度:0

    http://poj.org/problem?id=2253 #include <iostream> #include <queue> #include <cmath&g ...

  3. POJ 2253 Frogger ( 最短路变形 || 最小生成树 )

    题意 : 给出二维平面上 N 个点,前两个点为起点和终点,问你从起点到终点的所有路径中拥有最短两点间距是多少. 分析 : ① 考虑最小生成树中 Kruskal 算法,在建树的过程中贪心的从最小的边一个 ...

  4. POJ 2253 Frogger -- 最短路变形

    这题的坑点在POJ输出double不能用%.lf而要用%.f...真是神坑. 题意:给出一个无向图,求节点1到2之间的最大边的边权的最小值. 算法:Dijkstra 题目每次选择权值最小的边进行延伸访 ...

  5. POJ 2253 Frogger (最短路)

    Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 28333   Accepted: 9208 Descript ...

  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 最短路

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

  9. POJ. 2253 Frogger (Dijkstra )

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

  10. POJ 2253 Frogger Floyd

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

随机推荐

  1. java Log4j封装,程序任何位置调用

    一般写log4j,每个类都会定义一个logger 明显这样太麻烦了, 然后封装了一下,明显好用多了. package tools; import java.io.IOException; import ...

  2. LeetCode——Find Minimum in Rotated Sorted Array

    Description: Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 ...

  3. LeetCode——Contains Duplicate II

    Description: Given an array of integers and an integer k, find out whether there there are two disti ...

  4. vue报错一

    8080端口被占用 解决方案: 打开cmd输入:netstat -ano查看所有端口信息,如图,找到端口 8080,以及对应的 PID: 输入:tskill PID 即可杀死进程,ex:: tskil ...

  5. ubuntu解压命令

    .tar.gz 解压缩文件:  tar zxvf a.tar.gz 压缩文件命令:tar -zcvf test3.tar.gz  test1 test2 此命令是将两个文件夹 或文件同时压缩到一个文件 ...

  6. iconfont阿里爸爸做的开源图库

    iconfont 三种使用姿势 1.unicode格式 优点 兼容性最好,支持ie6+ 支持按字体的方式去动态调整图标大小,颜色等等 缺点 不支持多色图标 在不同的设备浏览器字体的渲染会略有差别,在不 ...

  7. 【BZOJ3529】[Sdoi2014]数表 莫比乌斯反演+树状数组

    [BZOJ3529][Sdoi2014]数表 Description 有一张N×m的数表,其第i行第j列(1 < =i < =礼,1 < =j < =m)的数值为能同时整除i和 ...

  8. MDK软件仿真常见问题

    一直不知道MDK该怎么仿真调试程序,之前试了好几次都没有成功.因为有个程序一直不知道里面的变量对应着外部怎么的模式,今天想起可以用仿真调试的方法查看当外部设置某种模式的时候, 内部变量的变化,这样想来 ...

  9. find the safest road---hdu1596(最短路模板求最大概率)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1596 求给定的任意两点之间的最大安全概率,概率之间是相乘的关系,所以注意初始化即可 #include& ...

  10. Ultra-QuickSort---poj2299 (归并排序.逆序数.树状数组.离散化)

    题目链接:http://poj.org/problem?id=2299 题意就是求把数组按从小到大的顺序排列,每次只能交换相邻的两个数, 求至少交换了几次 就是求逆序数 #include<std ...