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 ...
随机推荐
- redhat7.6 AIDE 系统文件完整性检查工具
1.安装AIDE yum install aide 安装完的配置文件,在/etc/aide.conf 自定义/etc/aide.conf 下面我写了对 /data/data1 目录做CONTE ...
- leetCode练题——13. Roman to Integer
1.题目13. Roman to Integer Roman numerals are represented by seven different symbols: I, V, X, L, C, D ...
- 语言国际化:中文ASC码互转
https://javawind.net/tools/native2ascii.jsp 1.首先找到了上面的链接,也就是下图,输入中文就可立即得出ASCII码 2.看到上图第一条,找到了JDK/bin ...
- unittest中的parameterized参数化
一.安装插件 pip install parameterized 二.有默认参数情况与没有默认参数情况---1 注意:这种写法,只能给单个用例进行参数化,不能给多个用例使用,要每个用例都进行参数化. ...
- jarvisoj fm
使用指令 checksec 查看保护情况 Arch: i386-32-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PI ...
- sparkRDD:第1节 RDD概述;第2节 创建RDD
RDD的特点: (1)rdd是数据集: (2)rdd是编程模型:因为rdd有很多数据计算方法如map,flatMap,reduceByKey等: (3)rdd相互之间有依赖关系: (4)rdd是可以分 ...
- Django问题 Did you rename .....a ForeignKey
给新加入的字段添加一个default默认值即可,让字段非空.然后在进行makemigrations,完成操作后删除相关默认值即可.
- RIFF
RIFF全称为资源互换文件格式(Resources Interchange File Format),是Windows下大部分多媒体文件遵循的一种文件结构. RIFF文件所包含的数据类型由该文件的扩展 ...
- 在Centos 7.7下用minikube部署单节点kubernetes.
centos8 下用yum安装docker-ce会报错,说明docker-ce对centos8支持还不太好.所以在centos7.7下安装 先更新一下系统 yum update 安装 yum工具, ...
- mysql时出现:is not allowed to connect to this MySQL serverConnection closed by foreign host问题的解决
这个原因是因为索要链接的mysql数据库只允许其所在的服务器连接,需要在mysql服务器上设置一下允许的ip权限,如下: 1.连接mysql mysql -u root -p 1 如图: 2.授权 g ...