题意:给出一堆点,求从起点到终点的所有通路中相邻点的距离的最大值的最小值。(意思就是自己百度吧……)

解法:用相邻点的最大值作为权值代替路径的距离跑最短路或者最小生成树。然后我写了一个我以为是优化过的dijkstra但好像是prim的东西- -啊差不多啦……

总之用优先队列维护权值进行广搜……然后交G++一直wa也不知道为啥……交了C++就过了……

代码:

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<time.h>
#include<stdlib.h>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#define LL long long
using namespace std;
struct node
{
int x, y;
}p[205];
struct node1
{
int point;
int step;
node1(int point, int step) : point(point), step(step) {}
node1() {}
bool operator < (const node1 &tmp) const
{
return step > tmp.step;
}
};
int n;
int caldis(node a, node b)
{
return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}
int dis[205][205];
vector <int> edge[205];
bool vis[205];
double bfs()
{
memset(vis, 0, sizeof vis);
priority_queue <node1> q;
q.push(node1(0, 0.0));
while(!q.empty())
{
node1 tmp = q.top();
q.pop();
vis[tmp.point] = 1;
if(tmp.point == 1) return tmp.step;
for(int i = 0; i < edge[tmp.point].size(); i++)
{
if(!vis[edge[tmp.point][i]]) q.push(node1(edge[tmp.point][i], max(tmp.step, dis[tmp.point][edge[tmp.point][i]])));
}
}
}
int main()
{
int cse = 1;
while(~scanf("%d", &n) && n)
{
for(int i = 0; i < n; i++)
scanf("%d%d", &p[i].x, &p[i].y);
int maxn = 0.0;
for(int i = 0; i < n; i++)
edge[i].clear();
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
{
if(i == j) continue;
int tmp = caldis(p[i], p[j]);
edge[i].push_back(j);
dis[i][j] = tmp;
}
double ans = bfs();
printf("Scenario #%d\nFrog Distance = %.3lf\n\n", cse++, sqrt(ans));
}
return 0;
}

  

POJ 2253 Difference of Clustering的更多相关文章

  1. 最短路(Floyd_Warshall) POJ 2253 Frogger

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

  2. poj 2253 Frogger (最长路中的最短路)

    链接:poj 2253 题意:给出青蛙A,B和若干石头的坐标,现青蛙A想到青蛙B那,A可通过随意石头到达B, 问从A到B多条路径中的最长边中的最短距离 分析:这题是最短路的变形,曾经求的是路径总长的最 ...

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

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

  4. POJ. 2253 Frogger (Dijkstra )

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

  5. POJ 2253 ——Frogger——————【最短路、Dijkstra、最长边最小化】

    Frogger Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Stat ...

  6. HDU 5489 Difference of Clustering 图论

    Difference of Clustering Problem Description Given two clustering algorithms, the old and the new, y ...

  7. HDU 5486 Difference of Clustering 暴力模拟

    Difference of Clustering HDU - 5486 题意:有n个实体,新旧两种聚类算法,每种算法有很多聚类,在同一算法里,一个实体只属于一个聚类,然后有以下三种模式. 第一种分散, ...

  8. POJ 2253 Frogger(dijkstra 最短路

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

  9. Poj(2253),Dijkstra松弛条件的变形

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

随机推荐

  1. 关联式容器(associative containers)

    关联式容器(associative containers) 根据数据在容器中的排列特性,容器可分为序列式(sequence)和关联式(associative)两种. 标准的STL关联式容器分为set( ...

  2. ORA-12560: TNS: 协议适配器错误 解决

    传统方法: 大多数网站都有记载三个方法解决 但是出现上述错误另一个原因: 刚刚安装的Oracle 里面的账户都是锁定的 需要解锁 见如下的Oracle11g安装过程 http://www.2cto.c ...

  3. 李洪强iOS开之【零基础学习iOS开发】【02-C语言】04-常量、变量

    在我们使用计算机的过程中,会接触到各种各样的数据,有文档数据.图片数据.视频数据,还有聊QQ时产生的文字数据.用迅雷下载的文件数据等.这讲我们就来介绍C语言中数据的处理. 一.数据的存储 1.数据类型 ...

  4. C 语言学习guideline

    Kernighan和Ritchie的<The C Programming Language>(中译名<C程序设计语言>)堪称经典中的经典,不过旧版的很多内容都已过时,和现在的标 ...

  5. C语言命名规则

    一.程序风格:          1.严格采用阶梯层次组织程序代码:          各层次缩进的分格采用VC的缺省风格,即每层次缩进为4格,括号位于下一行.     要求相匹配的大括号在同一列,对 ...

  6. 百度全新的ARM架构服务器,一个2U机箱装6台,每台4个3T硬盘,每个机箱共72TB

    1月11日,中国科学院原秘书长.国家科技重大专项国务院咨询评估组专家侯自强,来到百度南京数据中心,和他一起的还有中国工程院院士倪光南以及工业和信息化部电信研究院传输研究所副所长石友康等人.他们看到的是 ...

  7. TCoolMemo

    我们先起个名字叫做TCoolMemo.以上篇已经讲了很多组件的技术,这里就只说出几个重点.其余不多说了. 首先,该Memo从CustomMemo继承,它有这样外观:属于平面的,边框是可以设置颜色的线, ...

  8. Photoshop:去掉投影

    原图: 步骤: 1.图像->调整->黑白 (ctrl+shift+alt+B),-200 2.加渐变映射层配合合适的图层混合模式 结果:

  9. Linux进程的睡眠和唤醒简析

    COPY FROM:http://www.2cto.com/os/201204/127771.html 1 Linux进程的睡眠和唤醒 在Linux中,仅等待CPU时间的进程称为就绪进程,它们被放置在 ...

  10. C++RAII

    http://baike.baidu.com/view/1120455.htm?fr=aladdin http://www.cnblogs.com/gnuhpc/archive/2012/12/04/ ...