POJ 2253 Frogger (Floyd)
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions:57696 | Accepted: 18104 |
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
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
- 思路
有i, j, k 三个点,如果i到j的距离比i到k,k到j的距离都大,那就先跳到k,再跳到j,否则,就直接跳到j。
由此我们可知,这个更新的方式,与最短路略有不同。- 代码
- #include<iostream>
- #include<cmath>
- #include<cstdio>
- #include<cstring>
- #include<queue>
- using namespace std;
- double d[][];
- int a[][],n;
- int main()
- {
- int T;
- T=;
- while(cin>>n&&n){
- T++;
- memset(d,,sizeof(d));
- for(int i=;i<=n;i++){
- cin>>a[i][]>>a[i][];
- }
- for(int i=;i<=n;i++){
- for(int k=i+;k<=n;k++){
- d[i][k]=d[k][i]=sqrt((double)((a[i][]-a[k][])*(a[i][]-a[k][])+(a[i][]-a[k][])*(a[i][]-a[k][])));
- }
- }
- for(int k=;k<=n;k++){
- for(int j=;j<=n;j++){
- for(int i=;i<=n;i++){
- if(d[i][j]>d[i][k]&&d[i][j]>d[k][j]){
- d[j][i]=d[i][j]=max(d[i][k],d[k][j]);
- }
- }
- }
- }
- printf("Scenario #%d\nFrog Distance = %.3f\n\n",T,d[][]);
- }
- }
POJ 2253 Frogger (Floyd)的更多相关文章
- POJ 2253 Frogger(floyd)
http://poj.org/problem?id=2253 题意 : 题目是说,有这样一只青蛙Freddy,他在一块石头上,他呢注意到青蛙Fiona在另一块石头上,想去拜访,但是两块石头太远了,所以 ...
- POJ 2253 Frogger(最小生成树)
青蛙跳跃,题意大概是:青蛙从起点到终点进行一次或多次的跳跃,多次跳跃中肯定有最大的跳跃距离.求在所有的跳跃中,最小的最大跳跃距离SF-_-(不理解?看题目吧). 可以用最小生成树完成.以起点为根,生成 ...
- poj 2253 Frogger(floyd变形)
题目链接:http://poj.org/problem?id=1797 题意:给出两只青蛙的坐标A.B,和其他的n-2个坐标,任一两个坐标点间都是双向连通的.显然从A到B存在至少一条的通路,每一条通路 ...
- POJ. 2253 Frogger (Dijkstra )
POJ. 2253 Frogger (Dijkstra ) 题意分析 首先给出n个点的坐标,其中第一个点的坐标为青蛙1的坐标,第二个点的坐标为青蛙2的坐标.给出的n个点,两两双向互通,求出由1到2可行 ...
- 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 (dijkstra最短路)
题目链接:http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS Memory Limit: 65536K Total Submissi ...
- POJ 2253 Frogger(最短路&Floyd)题解
题意:想给你公青蛙位置,再给你母青蛙位置,然后给你剩余位置,问你怎么走,公青蛙全力跳的的最远距离最小. 思路:这里不是求最短路径,而是要你找一条路,青蛙走这条路时,对他跳远要求最低.这个思想还是挺好迁 ...
- [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 Description Freddy Frog is sitting on a stone in the middle of ...
随机推荐
- phonegap-plugin-contentsync
一.API 1.ContentSync.sync(options) options.src : 字符串类型 (必选项)远程托管内容的URL.更新一个生产环境下的APP,常使用HTTPS option ...
- 转载:关于JESD204B转换器与FPGA匹配的设计关键点
http://www.dzsc.com/data/2014-11-27/107442.html 随着更多的模数转换器(ADC)和数模转换器(DAC)支持最新的JESD204B串行接口标准,出现了FPG ...
- 如何在虚拟机下配置centOS7
链接地址:https://baijiahao.baidu.com/s?id=1597320700700593557&wfr=spider&for=pc
- codeforces722B
Verse Pattern CodeForces - 722B You are given a text consisting of n lines. Each line contains some ...
- 2018-南京网络赛icpc-L题(分层最短路)
题意:给你n个点,m条边的有向带权图,然后你每次可以选<=k条边的边权变成0,问你1到n的最短路: 解题思路:这道题基本上就是原题了呀,bzoj2763(无向图),解法就是拆点跑分层的最短路,比 ...
- Maven使用(一)—— Maven的安装与全局配置
一.Maven安装 Maven的安装步骤: 1.Maven官网(http://maven.apache.org/)下载压缩包,解压缩,当前最新版本是apache-maven-3.5.3-bin.zip ...
- 第四十天 并发编程之io模型
一.今日内容 1.网络IO的两个阶段 waitdata copydata 2阻塞IO模型 之前写的都是阻塞 无论多线程 多进程 还是 进程池 线程池 3.非阻塞IO模型 在非阻塞IO中 需要不断循环询 ...
- 【BZOJ5212】[ZJOI2018]历史(Link-Cut Tree)
[BZOJ5212][ZJOI2018]历史(Link-Cut Tree) 题面 洛谷 BZOJ 题解 显然实际上就是给定了一棵树和每个点被\(access\)的次数,求解轻重链切换的最大次数. 先考 ...
- pip 安装第三方包提示Unknown or unsupported command 'install'
Unknown or unsupported command 'install' Unknown or unsupported command 'show' Unknown or unsupporte ...
- urllib的实现---timeout,获取http响应码,重定向,proxy的设置
1.Timeout设置超时 只能修改Socket设置全局Timeout #! /usr/bin/env python3 import socket import urllib.request # ti ...