poj 2253 Frogger (dijkstra最短路)
| Time Limit: 1000MS | Memory Limit: 65536K | |
| Total Submissions: 25773 | Accepted: 8374 |
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
Source

#include <stdio.h>
#include <math.h>
const int INF=;
double map[][],node[],Min;
int n,vis[]; double Max(double a,double b)
{
return a>b?a:b;
} void dijkstra()
{
int i,j,k,m;
for (i=; i<n; i++)
{
node[i]=map[][i];
vis[i]=;
}
vis[]=;
for (k=; k<n; k++)
{
Min=INF;
m=-;
for (i=; i<n; i++)
if (!vis[i])
{
if (Min>node[i])
{
Min=node[i];
m=i;
}
}
if (m==-)
break;
vis[m]=;
//tm=m;
for (i=; i<n; i++)
{
if (!vis[i]&&Max(node[m],map[m][i])<node[i])
node[i]=Max(node[m],map[m][i]); }
}
} int main ()
{
double a[],b[];
int count=,i,j;
while (scanf("%d",&n),n)
{
for (i=; i<n; i++)
{
scanf("%lf%lf",&a[i],&b[i]);
}
for (i=; i<n; i++)
{
for (j=; j<n; j++)
{
map[i][j]=map[j][i]=(a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j]); }
}
dijkstra();
printf("Scenario #%d\n", ++count);
printf("Frog Distance = %.3f\n\n", sqrt(node[]));
}
return ;
}
poj 2253 Frogger (dijkstra最短路)的更多相关文章
- POJ 2253 ——Frogger——————【最短路、Dijkstra、最长边最小化】
Frogger Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Stat ...
- POJ - 2253 Frogger(最短路Dijkstra or flod)
题意:要从起点的石头跳到终点的石头,设The frog distance为从起点到终点的某一路径中两点间距离的最大值,问在从起点到终点的所有路径中The frog distance的最小值为多少. 分 ...
- POJ 2253 - Frogger - [dijkstra求最短路]
Time Limit: 1000MS Memory Limit: 65536K Description Freddy Frog is sitting on a stone in the middle ...
- POJ 2253 Frogger【最短路变形——路径上最小的最大权】
链接: http://poj.org/problem?id=2253 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22010#probl ...
- poj 2253 Frogger dijkstra算法实现
点击打开链接 Frogger Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 21653 Accepted: 7042 D ...
- poj 2253 Frogger (最短路变种,连通图的最长边)
题目 这里的dijsktra的变种代码是我看着自己打的,终于把代码和做法思路联系上了,也就是理解了算法——看来手跟着画一遍真的有助于理解. #define _CRT_SECURE_NO_WARNING ...
- 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 ...
- POJ 2253 Frogger(最短路&Floyd)题解
题意:想给你公青蛙位置,再给你母青蛙位置,然后给你剩余位置,问你怎么走,公青蛙全力跳的的最远距离最小. 思路:这里不是求最短路径,而是要你找一条路,青蛙走这条路时,对他跳远要求最低.这个思想还是挺好迁 ...
- 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 )
POJ. 2253 Frogger (Dijkstra ) 题意分析 首先给出n个点的坐标,其中第一个点的坐标为青蛙1的坐标,第二个点的坐标为青蛙2的坐标.给出的n个点,两两双向互通,求出由1到2可行 ...
随机推荐
- Vue于React特性简单对比(一)
一,对象实体对比 vue的对象实体依然是html,而react的对象实体已经变味jsx,一种新的语法结构. vue的html与react的jsx都可以进行拆分,拆分成更细小的组件,组件之间可以传值. ...
- [C/C++] C/C++错题集
1. 解析: A:在GCC下输出:0 在VC6.0下输出:1 B:在GCC下输出:段错误 (核心已转储) 在VC6.0下输出:已停止工作,出现了一个问题,导致程序停止正常工作. C:正常 ...
- MVC绕过登陆界面验证时HttpContext.Current.User.Identity.Name取值为空问题解决方法
Global.asax界面添加如下方法: void FormsAuthentication_Authenticate(object sender, FormsAuthenticationEventAr ...
- poj3074-Sodoku
解数独. 分析 考虑如何把数独解合法的条件转化为经典的01精确覆盖: 每个格子只能填一个数,1-9 每一列刚好填了1-9 每一行刚好填了1-9 每个九宫格刚好填了1-9 也就是说,每个格子,列,行,九 ...
- Python 文件对象和方法
Python文件对象和方法 1.打开和关闭文件 Python提供了必要的函数和方法进行默认情况下的文件基本操作,我们可以用file对象做大部分文件操作. open()方法 我们必须先用Python内置 ...
- C# 大文件的复制方法
如何复制读取大文件,也许困惑了很多人很长时间,这个不知道怎么搞,的确让人头疼欲裂,知道了你就才发现原来那么简单,话不多说,直入正题```` static void Main(string[] args ...
- 【题解】51nod1967 路径定向
第一次写欧拉回路,实际上只要dfs下去就可以了,反正每条边都是要遍历一遍的…… 关键有两个性质:1.一个无向图存在欧拉回路,当且仅当该图所有顶点度数都为偶数,且该图是连通图.2.一个有向图存在欧拉回路 ...
- angularJS新增 品优购新增品牌
前台代码 brand.html <!DOCTYPE html> <html> <head> <meta charset="utf-8"&g ...
- Apache 403 错误解决方法-让别人可以访问你的服务器(转)
有一次做好了一个效果放在自己电脑的服务器上,让同学查看(同处于校园网中),却不知apache一直显示403 错误,对方没有权限访问,我知道这应该是配置文件httpd.conf中的问题,网上搜了一下其他 ...
- phalcon安装
参考网站:https://docs.phalconphp.com/zh/latest/reference/tools.html (中文版)cento6.5环境安装:cd ~mkdir phalconc ...