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可行 ...
随机推荐
- 【linux】- nohup 和 &
&的意思是在后台运行, 什么意思呢? 意思是说,当你在执行 ./a.out & 的时候,即使你用ctrl C,那么a.out照样运行(因为对SIGINT信号免疫).但是要注意,如果你直 ...
- 新建maven工程问题001
这周一直在研究SpringMVC+Mybatis,有些心得,记录一下. Ⅰ:建maven遇到的问题. 1.1 新建maven时选中[Create a simple project]这样,后面[Pack ...
- Jekyll 使用 Rouge 主题
今日发现我的 Github Pages 中的代码并没有高亮,看了一下代码发现,原来的没有设置 css 样式的原因,我使用的代码高亮器是 rouge highlighter: rouge Rouge 是 ...
- [计算机网络-传输层] 面向连接的传输:TCP
参考:http://blog.csdn.net/macdroid/article/details/49070185 在学习TCP之前我们先来看一下可靠数据传输需要提供什么样的机制: ·差错检测机制:检 ...
- MVC 枚举 转 SelectListItem
ViewBag.userlevel = new SelectList(Enum.GetNames(typeof(AdminLevels)),"", "", te ...
- BZOJ 1875 HH去散步(矩阵快速幂)
题意: 给定一张无向图,每条路的长度都是1,没有自环,可能有重边,给定起点与终点,求从起点走t步到达终点的方案数. 每一步走的时候要求不能走上一条刚刚走的路. 解析: 显然需要搞出个矩阵之后矩乘. 然 ...
- Vika and Segments - CF610D
Vika has an infinite sheet of squared paper. Initially all squares are white. She introduced a two-d ...
- 项目管理---git----快速使用git笔记(四)------远程项目代码的首次获取
使用git最常见的场景是 你需要参与到一个项目中,而这个项目的代码,同事已经上传到github或者https://coding.net了. 这时候他会给你一个项目代码的远程仓库链接. 例如: http ...
- 专题训练之2-sat
推荐几篇博客:https://blog.csdn.net/JarjingX/article/details/8521690 研究总结2-sat问题 https://blog.csdn.net/wher ...
- django-jet 中文文档
关于 JET是新式的Django管理界面并且增强了功能. 内容 文档 开始 安装django-jet 安装仪表盘 配置 配置文件 自动补全 紧凑内联 过滤器 仪表盘 自定义仪表盘 仪表盘模块 ...