Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sitting on another stone. He plans to visit her, but since the water is dirty and full of tourists' sunscreen, he wants to avoid swimming and instead reach her 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

The input will contain one or more test cases. The first line of each test case will contain the number of stones n (2<=n<=200). The next n lines each contain two integers xi,yi (0 <= xi,yi <= 1000) representing the coordinates of stone #i. Stone #1 is Freddy's 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

For each test case, print a line saying "Scenario #x" and a line saying "Frog Distance = y" where x is replaced by the test case number (they are numbered from 1) and y is replaced by the appropriate real number, printed to three decimals. Put a blank line after each test case, even after the la
 
题意比较难懂,难点也在于转换题意
题意:找a-b所有路径中最大步数里面最小的
 
本来先用最小生成树写的,但是没写出来:
 #include<iostream>
#include<string.h>
#include<cmath>
#include<iomanip>
#define inf 0x3f3f3f3f
using namespace std;
//kruskal int n,p; struct edge
{
double x;
double y;
}e[]; double addedge[];
int f[];
double pre[]; double cmp1(double x,double y)
{
return x<y;
} double d(double x1,double y1,double x2,double y2)
{
return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
} void init()
{
for(int i=;i<p;i++)
f[i]=i;
return ;
} int getf(int x)
{
if(f[x]==x)
return x;
return getf[f[x]];
} int merge(int x,int y)
{
int t1=merge(x);
int t2=merge(y);
if(t1!=t2)
{
f[t2]=t1;
return ;
}
return ;
} int main()
{
std::ios::sync_with_stdio(false);
cin.tie();
cout.tie(); while(cin>>n)
{
if(n==)
break;
memset(e,,sizeof(e));
memset(addedge,,sizeof(addedge));
memset(f,,sizeof(f));
for(int i=;i<n;i++)
cout<<e[i].x<<e[i].y;
p=;//p条边
for(int i=;i<n;i++)
{
for(int j=i+;j<n;j++)
{
addedge[p++]=d(e[i].x,e[i].y,e[j].x,e[j].y);
}
}
sort(addedge+,addedge+p+,cmp1); init();
int minmaxx=-inf;
int countt=;
int q=;
for(int i=;i<p;i++)
{
for(int j=i+;j<p;j++)
{
if(merge(addedge[i],addedge[j])==)//说明还未连通
{
countt++;
pre[q++]=
minmaxx=max(minmaxx,) }
if(countt==p-)
break;
} } int tt=;
cout<<"Scenario #"<<tt++<<endl;
cout<<"Frog Distance = ";
cout<<setiosflags(ios::fixed)<<setprecision()<<dis<<endl;
}
return ;
}

AC的是用那个五行代码过的:

 #include<iostream>
#include<string.h>
#include<cmath>
#include<iomanip>
#define inf 0x3f3f3f3f
using namespace std; //点点之间的距离floyd
//找a-b所有路径中最大步数里面最小的
struct edge
{
// double x;
// double y;
int x;
int y;
} e[]; double a[][];
int n; double d(int x1,int y1,int x2,int y2)
{
return sqrt(((x2-x1)*(x2-x1)*1.0+(y2-y1)*(y2-y1)*1.0)*1.0);
} void init()
{
for(int i=;i<=n;i++)
{
for(int j=;j<=n;j++)
{
if(i==j)
a[i][j]=;
else
a[i][j]=inf;
}
}
} int main()
{
std::ios::sync_with_stdio(false);
cin.tie();
cout.tie();
int tt=;
while(cin>>n)
{
if(n==)
break;
memset(e,,sizeof(e));
memset(a,,sizeof(a));
init();
for(int i=; i<=n; i++)//n个顶点
cin>>e[i].x>>e[i].y; // p=1;//p条边 for(int i=; i<=n; i++)
{
for(int j=i+; j<=n; j++)
{
// addedge[p++]=d(e[i].x,e[i].y,e[j].x,e[j].y); double dd=d(e[i].x,e[i].y,e[j].x,e[j].y);
if(a[i][j]>dd||a[j][i]>dd)
{
a[j][i]=a[i][j]=dd;
}
}
}
// sort(addedge+1,addedge+p+1,cmp1);
for(int k=;k<=n;k++)
{
for(int i=;i<=n;i++)
{
for(int j=;j<=n;j++)
{
//if(a[i][j]a[i][k]+a[k][j])
a[i][j]=min(a[i][j],max(a[i][k],a[k][j]));
}
}
}
double dis=a[][];
cout<<"Scenario #"<<tt++<<endl;
cout<<"Frog Distance = ";
cout<<setiosflags(ios::fixed)<<setprecision()<<dis<<endl<<endl;
}
return ;
}

POJ-2253-Frogger-/Floyd-Warshall/的更多相关文章

  1. POJ 2253 Frogger Floyd

    原题链接:http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissi ...

  2. POJ 2253 Frogger floyd算法

    题目:click here 题意: 给出两只青蛙的坐标A.B,和其他的n-2个坐标,任意两坐标间是双向连通的.显然从A到B存在至少一条的通路,每一条通路的元素都是这条通路中前后两个点的距离,这些距离中 ...

  3. POJ 2253 Frogger(warshall算法)

    题意:湖中有很多石头,两只青蛙分别位于两块石头上.其中一只青蛙要经过一系列的跳跃,先跳到其他石头上,最后跳到另一只青蛙那里.目的是求出所有路径中最大变长的最小值(就是在到达目的地的路径中,找出青蛙需要 ...

  4. 最短路(Floyd_Warshall) POJ 2253 Frogger

    题目传送门 /* 最短路:Floyd算法模板题 */ #include <cstdio> #include <iostream> #include <algorithm& ...

  5. POJ 2253 Frogger ,poj3660Cow Contest(判断绝对顺序)(最短路,floyed)

    POJ 2253 Frogger题目意思就是求所有路径中最大路径中的最小值. #include<iostream> #include<cstdio> #include<s ...

  6. POJ. 2253 Frogger (Dijkstra )

    POJ. 2253 Frogger (Dijkstra ) 题意分析 首先给出n个点的坐标,其中第一个点的坐标为青蛙1的坐标,第二个点的坐标为青蛙2的坐标.给出的n个点,两两双向互通,求出由1到2可行 ...

  7. POJ 2253 Frogger(dijkstra 最短路

    POJ 2253 Frogger Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fion ...

  8. POJ 2253 Frogger

    题目链接:http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissi ...

  9. poj 2253 Frogger 最小瓶颈路(变形的最小生成树 prim算法解决(需要很好的理解prim))

    传送门: http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissi ...

  10. poj 2253 Frogger (dijkstra最短路)

    题目链接:http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissi ...

随机推荐

  1. vue footer点击变色

    <header class="tab_nav"> <div v-for="(item,index) in tabNav" @click=&qu ...

  2. 异或空间求基(模板)——hdu3949

    输出样例有点问题的.. #include<bits/stdc++.h> using namespace std; #define ll unsigned long long #define ...

  3. 给标签设置disabled属性后提交不了数据

    项目中遇到给select标签添加disabled属性然后提交表单的时候不能提交该表单的数据到后台, readonly属性对提交数据没有限制,但是readonly属性对radio.select.chec ...

  4. NX二次开发-UFUN遍历函数UF_OBJ_cycle_objs_in_part

    NX11+VS2013 #include <uf.h> #include <uf_obj.h> #include <uf_modl.h> #include < ...

  5. NX二次开发-获取按钮的ID UF_MB_ask_button_id

    NX9+VS2012 1.打开D:\Program Files\Siemens\NX 9.0\UGII\menus\ug_main.men 找到装配和PMI,在中间加上一段 TOGGLE_BUTTON ...

  6. [转]gulp打包工具总结

    与grunt类似,gulp也是构建工具,但相比于grunt的频繁IO操作,gulp的流操作能更快更便捷地完成构建工作.gulp借鉴了Unix操作系统的管道(pipe)思想,前一级的输出,直接变成后一级 ...

  7. JVM内核-原理、诊断与优化学习笔记(五):GC参数

    文章目录 堆的回顾 串行收集器 并行收集器 ParNew(par-并行的缩写,new-新生代,所以只是新生代并行) Parallel收集器 参数设置 -XX:MaxGCPauseMills -XX:G ...

  8. MySQL数据库迁移详细步骤

    转载自:http://sofar.blog.51cto.com/353572/1598364 ===================================================== ...

  9. postgresql-创建主键自增的表

    之前一直用的mysql,这个也基本上是主流,主键自增是很多建表规范中的硬性要求,不过这两种数据库主键自增的区别还是很大的 通常navicat中对mysql 主键自增直接客户端指定即可,不过对PG貌似不 ...

  10. 将Mysq数据导入solr索引库

    本文的基础环境都是在centos 64bit,jdk1.7.79 将mysql 的jar 包添加到/home/hadoop/cloudsolr/solr-4.10.4/contrib/dataimpo ...