题目链接:Frogger

题意:两仅仅青蛙,A和B,A想到B哪里去,可是A得弹跳有限制,所以不能直接到B,可是有其它的石头作为过渡点,能够通过他们到达B,问A到B的全部路径中。它弹跳最大的跨度的最小值

PS:最小生成树过的,刚開始用Dijstra做,Kao,精度损失的厉害,对于Dijksra的变形不大会变啊,看了Discuss有人用最小生成树过,我一划拉,还真是。敲了,就过了,等会研究研究最短路的各种变形,有模板不会变,不会灵活应用,渣渣就是渣渣。

ME               Time

1017Kb          0Ms

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <algorithm>
const int INF = 1e8;
const int N = 205;
using namespace std;
struct node{
int x,y;
}g[N];
int n,vis[N];
double mapp[N][N],dis[N];
double Prim()
{
int pos;
double maxe=0,minn;
for(int i=1;i<=n;i++)
{
dis[i]=mapp[1][i];
vis[i]=0;
}
vis[1]=1;
dis[1]=0;
for(int i=1;i<=n;i++)
{
minn=INF;
pos=1;
for(int j=1;j<=n;j++)
{
if(!vis[j]&&dis[j]<minn)
{
pos=j;
minn=dis[j];
}
}
if(minn>maxe)
maxe=minn;
if(pos==2) //假设当前构树条件是2号哇,那么直接返回,无其它路线了
return maxe;
vis[pos]=1;
for(int j=1;j<=n;j++)
if(!vis[j] &&mapp[pos][j] < dis[j])
{
dis[j] = mapp[pos][j];
}
}
return dis[2];
}
void init(int i)
{
double t;
mapp[i][i]=0;
for(int j=1;j<i;j++)
{
t=sqrt((g[i].x-g[j].x)*(g[i].x-g[j].x)+(g[i].y-g[j].y)*(g[i].y-g[j].y));
mapp[i][j] = t;
mapp[j][i] = t;
}
}
int main()
{
int c=0;
double st;
while(scanf("%d",&n),n)
{
for(int i=1;i<=n;i++)
{
scanf("%d%d",&g[i].x,&g[i].y);
init(i);
}
st = Prim();
printf("Scenario #%d\n",++c);
printf("Frog Distance = %.3f\n\n",st);//看了Discuss 知道。POJ不能%.3lf
}
return 0;
}



POJ 2253-Frogger (Prim)的更多相关文章

  1. POJ 2253 Frogger(最小生成树)

    青蛙跳跃,题意大概是:青蛙从起点到终点进行一次或多次的跳跃,多次跳跃中肯定有最大的跳跃距离.求在所有的跳跃中,最小的最大跳跃距离SF-_-(不理解?看题目吧). 可以用最小生成树完成.以起点为根,生成 ...

  2. POJ 2253 Frogger(floyd)

    http://poj.org/problem?id=2253 题意 : 题目是说,有这样一只青蛙Freddy,他在一块石头上,他呢注意到青蛙Fiona在另一块石头上,想去拜访,但是两块石头太远了,所以 ...

  3. POJ 2253 Frogger (Floyd)

    Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissions:57696   Accepted: 18104 Descript ...

  4. POJ. 2253 Frogger (Dijkstra )

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

  5. POJ 2253 Frogger(dijkstra 最短路

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

  6. poj 2253 Frogger (dijkstra最短路)

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

  7. [ACM] POJ 2253 Frogger (最短路径变形,每条通路中的最长边的最小值)

    Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 24879   Accepted: 8076 Descript ...

  8. poj 2253 Frogger(floyd变形)

    题目链接:http://poj.org/problem?id=1797 题意:给出两只青蛙的坐标A.B,和其他的n-2个坐标,任一两个坐标点间都是双向连通的.显然从A到B存在至少一条的通路,每一条通路 ...

  9. POJ - 2253 Frogger(Dijkstra变形题)

    题意: 题目撰写者的英语真是艰难晦涩,看了别人题解,才知道这题题意. 两个forger 一个froger 要蹦到另外一个froger处,他们的最短距离是这样定义的 : The frog distanc ...

  10. POJ 2253 Frogger(Dijkstra变形——最短路径最大权值)

    题目链接: http://poj.org/problem?id=2253 Description Freddy Frog is sitting on a stone in the middle of ...

随机推荐

  1. 灵活的运用Model类

    1.定义接口 using System; using System.Collections.Generic; using System.Linq; using System.Web; namespac ...

  2. 融云消息接口apicloud

    融云提供消息发送服务,支持个人消息,群消息,讨论组,聊天室消息, 以下是它涉及到的接口. 初始化,连接之后,可以使用. <!DOCTYPE html> <html> <h ...

  3. legend---六、php脚本变量的生命周期是怎样的

    legend---六.php脚本变量的生命周期是怎样的 一.总结 一句话总结:应该是脚本结束变量的生命周期就完了 1.外部js找不到元素是怎么回事? 1 function myDailyTaskFin ...

  4. mybatis :实现mybatis分页

    上一篇文章里已经讲到了mybatis与spring MVC的集成,并且做了一个列表展示,显示出所有article 列表,但没有用到分页,在实际的项目中,分页是肯定需要的.而且是物理分页,不是内存分页. ...

  5. 在C# 获取当前应用网址

    /// <summary>        /// 获取当前应用网址        /// </summary>        /// <returns></r ...

  6. 在navicat中如何新建连接数据库

    前几天给大家分享了如何安装Navicat,没有来得及上车的小伙伴可以戳这篇文章:手把手教你安装Navicat——靠谱的Navicat安装教程.今天给大家分享一下Navicat的简单使用教程,具体的教程 ...

  7. python数据处理技巧二

    python数据处理技巧二(掌控时间) 首先简单说下关于时间的介绍其中重点是时间戳的处理,时间戳是指格林威治时间1970年01月01日00时00分00秒(北京时间1970年01月01日08时00分00 ...

  8. Add Webhooks to Your API the Right Way

    Add Webhooks to Your API the Right Way Adam DuVander / December 15, 2016 In the last 10 years, APIs ...

  9. Windows7下修改pip源

    以下列举三种方式的pip源配置: 1. 设置环境变量PIP_CONFIG_FILE指向pip.ini源配置文件,pip.ini文件内容如下: [global] index-url = http://m ...

  10. ie中 专有的注释

    http://www.cnblogs.com/liluping860122/p/3539165.html