POJ培训计划2253_Frogger(最短/floyd)
解决报告
意甲冠军:
乞讨0至1所有最大的道路值的最小数量。
思维:
floyd。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#define inf 0x3f3f3f3f
using namespace std;
int n,m,q;
double mmap[210][210];
struct node {
double x,y;
} p[210];
double dis(node p1,node p2) {
return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
}
void floyd() {
for(int k=0; k<n; k++)
for(int i=0; i<n; i++)
for(int j=0; j<n; j++)
mmap[i][j]=min(mmap[i][j],max(mmap[i][k],mmap[k][j]));
}
int main() {
int i,j,u,v,w,k=1;
while(~scanf("%d",&n)) {
if(!n)break;
for(i=0; i<n; i++) {
for(j=0; j<n; j++)
mmap[i][j]=(double)inf;
mmap[i][i]=0;
}
for(i=0; i<n; i++) {
scanf("%lf%lf",&p[i].x,&p[i].y);
}
for(i=0; i<n; i++) {
for(j=0; j<n; j++) {
mmap[i][j]=dis(p[i],p[j]);
}
}
floyd();
printf("Scenario #%d\n",k++);
printf("Frog Distance = %.3lf\n",mmap[0][1]);
printf("\n");
}
return 0;
}
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 25958 | Accepted: 8431 |
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
POJ培训计划2253_Frogger(最短/floyd)的更多相关文章
- POJ 1125 Stockbroker Grapevine(floyd)
http://poj.org/problem?id=1125 题意 : 就是说想要在股票经纪人中传播谣言,先告诉一个人,然后让他传播给其他所有的经纪人,需要输出的是从谁开始传播需要的时间最短,输出这个 ...
- POJ 3216 最小路径覆盖+floyd
Repairing Company Time Limit: 1000MS Memory Limit: 131072K Total Submissions: 6646 Accepted: 178 ...
- POJ 3660 Cow Contest (Floyd)
http://poj.org/problem?id=3660 题目大意:n头牛两两比赛经过m场比赛后能判断名次的有几头可转 化为路径问题,用Floyd将能够到达的路径标记为1,如果一个点能 够到达剩余 ...
- poj 2253 Frogger(最短路 floyd)
题目:http://poj.org/problem?id=2253 题意:给出两只青蛙的坐标A.B,和其他的n-2个坐标,任一两个坐标点间都是双向连通的.显然从A到B存在至少一条的通路,每一条通路的元 ...
- POJ 1502 MPI Maelstrom( Spfa, Floyd, Dijkstra)
题目大意: 给你 1到n , n个计算机进行数据传输, 问从1为起点传输到所有点的最短时间是多少, 其实就是算 1 到所有点的时间中最长的那个点. 然后是数据 给你一个n 代表有n个点, 然后给你一 ...
- POJ 2391 Ombrophobic Bovines (Floyd + Dinic +二分)
Ombrophobic Bovines Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11651 Accepted: 2 ...
- POJ 1125 Stockbroker Grapevine【floyd简单应用】
链接: http://poj.org/problem?id=1125 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22010#probl ...
- POJ 3660—— Cow Contest——————【Floyd传递闭包】
Cow Contest Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit ...
- POJ 3660 Cow Contest 传递闭包+Floyd
原题链接:http://poj.org/problem?id=3660 Cow Contest Time Limit: 1000MS Memory Limit: 65536K Total Subm ...
随机推荐
- iOS - NSLog的使用方法
NSLog的定义 NSLog定义在NSObjCRuntime.h中,如下所示: void NSLog(NSString *format, …); 基本上,NSLog很像printf,同样会在conso ...
- [Xcode]SVN的使用
当发生冲突时: (p)postpone: -mark the conflict be resolved later 保持冲突,手动修改源文件解决冲突 (df)diff-full: -show all ...
- Ubuntu下Chromium源码的编译
一.失败的经历 印象中,谷歌建议Ubuntu建议版本为10.4.但是我找不到出处了,模糊的印象.不知道是不是这样? 1.Ubuntu10.4.3-desktop-amd64 + Virtual Box ...
- POJ2828 Buy Tickets 【线段树】+【单点更新】+【逆序】
Buy Tickets Time Limit: 4000MS Memory Limit: 65536K Total Submissions: 12296 Accepted: 6071 Desc ...
- Git中的merge命令实现和工作方式
想象一下有例如以下情形:代码库中存在两个分支,而且每一个分支都进行了改动.最后你想要将当中的一个分支合并到其它的分支中.个人博客网址 http://swinghu.github.com/ 那么要问合并 ...
- STL学习总结
STL就是Standard Template Library,标准模板库.这可能是一个历史上最令人兴奋的工具的最无聊的术语.从根本上说,STL是一些"容器"的集合.这些" ...
- Wamp 访问本地站点慢 的解决办法
自从安装了64位的windows 8.1之后,电脑运行速度变快了,可是重新下载安装64位的WAMP,访问本地的WEB站点确是很慢,根本不像是在本地访问,经过在WAMP论坛上搜索,终于找到了解决办法,主 ...
- TI推出SimpleLink低能耗蓝牙CC2541
TI推出SimpleLink低能耗蓝牙CC2541 日前,德州仪器 (TI) 宣布推出 SimpleLink™ 低能耗蓝牙 (Bluetooth®Low Energy) CC2541-Q1, 这是一款 ...
- CreateThread、_beginthreadex和AfxBeginThread 的区别
CreateThread._beginthreadex和AfxBeginThread 创建线程好几个函数可以使用,可是它们有什么区别,适用于什么情况呢?参考了一些资料,写得都挺好的,这里做一些摘抄和整 ...
- [PHP]利用MetaWeblog API实现XMLRPC功能
[PHP]利用MetaWeblog API实现XMLRPC功能 | OWNSELF [PHP]利用MetaWeblog API实现XMLRPC功能 Windows Live Writer是一款小巧的写 ...