POJ 2253:Frogger 求每一条路径最大值里面的最小值
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 31490 | Accepted: 10150 |
Description
by jumping.
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
stone, stone #2 is Fiona's stone, the other n-2 stones are unoccupied. There's a blank line following each test case. Input is terminated by a value of zero (0) for n.
Output
after each test case, even after the last one.
Sample Input
2
0 0
3 4 3
17 4
19 4
18 5 0
Sample Output
Scenario #1
Frog Distance = 5.000 Scenario #2
Frog Distance = 1.414
这个题目有些绕,实际上的意思是从点1到点2有很多条路径,每一条抵达的路径都有一个最大值。要求的是这些最大值里面的最小值。
举个例子:点1到点2,有两条路径可以到达,一条是1->3->2,一条是1->4->2。
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#pragma warning(disable:4996)
using namespace std; int num;
double stone[205][3];
double dis[205][205]; int main()
{
int i,j,k,ist=1;
while(cin>>num)
{
if(num==0)
break;
cout<<"Scenario #"<<ist<<endl;
ist++;
cout<<"Frog Distance = "; for(i=1;i<=num;i++)
{
cin>>stone[i][1]>>stone[i][2];
} for(i=1;i<=num;i++)
{
for(j=i+1;j<=num;j++)
{
dis[j][i]=dis[i][j]=(double)sqrt((stone[i][1]-stone[j][1])*(stone[i][1]-stone[j][1])+(stone[i][2]-stone[j][2])*(stone[i][2]-stone[j][2]));
}
} for(k=1;k<=num;k++)
{
for(i=1;i<=num;i++)
{
for(j=1;j<=num;j++)
{
dis[i][j]=min(dis[i][j],max(dis[i][k],dis[k][j]));
}
}
} printf("%.3f",dis[1][2]);
cout<<endl;
cout<<endl;
}
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
POJ 2253:Frogger 求每一条路径最大值里面的最小值的更多相关文章
- POJ 2253 Frogger【最短路变形——路径上最小的最大权】
链接: http://poj.org/problem?id=2253 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22010#probl ...
- POJ 2253 Frogger ,poj3660Cow Contest(判断绝对顺序)(最短路,floyed)
POJ 2253 Frogger题目意思就是求所有路径中最大路径中的最小值. #include<iostream> #include<cstdio> #include<s ...
- POJ. 2253 Frogger (Dijkstra )
POJ. 2253 Frogger (Dijkstra ) 题意分析 首先给出n个点的坐标,其中第一个点的坐标为青蛙1的坐标,第二个点的坐标为青蛙2的坐标.给出的n个点,两两双向互通,求出由1到2可行 ...
- 最短路(Floyd_Warshall) POJ 2253 Frogger
题目传送门 /* 最短路:Floyd算法模板题 */ #include <cstdio> #include <iostream> #include <algorithm& ...
- POJ 2253 Frogger(dijkstra 最短路
POJ 2253 Frogger Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fion ...
- POJ 2253 Frogger【最短路变形/最小生成树的最大权/最小瓶颈树/A到B多条路径中的最小的最长边】
Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sit ...
- [ACM] POJ 2253 Frogger (最短路径变形,每条通路中的最长边的最小值)
Frogger Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 24879 Accepted: 8076 Descript ...
- poj 2253 Frogger (dijkstra最短路)
题目链接:http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS Memory Limit: 65536K Total Submissi ...
- POJ 2253 ——Frogger——————【最短路、Dijkstra、最长边最小化】
Frogger Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Stat ...
随机推荐
- 「JSOI2014」电信网络
「JSOI2014」电信网络 传送门 一个点选了就必须选若干个点,最大化点权之和,显然最大权闭合子图问题. 一个点向它范围内所有点连边,直接跑最大权闭合子图即可. 参考代码: #include < ...
- 修改html内联样式的方法
问题:如下图弹出页面操作不了 分析:审查元素,发现是内联元素样式z-index:19891015导致的,修改内联元素样式z-index:0发现可以操作了 解决方法:内联样式优先级高,再引入css覆盖样 ...
- CentOS7虚拟机优化
CentOS7: 将网卡配置重点关注的地方为: [root@master ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33 BOOTPROTO=st ...
- Ollydbg使用问题汇总
1.可疑的断点 描述:看上去您想在一些命令的中间位置或数据中设置断点. 如果真是这样的话, 这些断点将不会执行并可能严重影响调试的程序. 您真的希望在此设置断点吗? 选择 否 的话还是会出现这个问题 ...
- Python学习第十一课——装饰器
#装饰器:本质就是函数,为其他函数附加功能原则:1.不修改被修饰函数的源代码2.不修改被修饰函数的调用方式 装饰器=高阶函数+函数嵌套+闭包 #高阶函数 ''' 高阶函数定义: 1.函数接受的参数是一 ...
- IIS 应用程序池回收(代码实现)
回收 public void StartStopRecycleApp(string appName = "项目DLL名称", string method = "Recyc ...
- 尝试实现一个简单的C语言string类型
用过`C++/Java/python/matlab/JS`等语言后,发现都能很轻松的使用string类型,而C只能这样: char str[] = "hello world"; o ...
- Django 学习 之 模板(html)与配置静态文件
一.模板(html) 1.模板语法之变量:语法为 {{ }} 在 Django 模板中遍历复杂数据结构的关键是句点字符, 语法:{{ var_name }} var_name 是一个变量名称,需要和 ...
- java实现邮箱发送邮件
第一步:封装发件人账号密码 import javax.mail.Authenticator;import javax.mail.PasswordAuthentication; /** * 发件人账号密 ...
- 如何反编译MIPS64伪代码?用Ghidra
在分析固件时,碰到MIPS64架构的程序会很头疼,虽然用IDA能够反编译出汇编代码,但是没办法F5一键反编译成伪代码,如果单看汇编,看久了脑壳痛. 后来Google到了一个好工具,Ghidra,发音和 ...