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

解法:用相邻点的最大值作为权值代替路径的距离跑最短路或者最小生成树。然后我写了一个我以为是优化过的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. python中精确输出JSON浮点数的方法

    有时需要在JSON中使用浮点数,比如价格.坐标等信息.但python中的浮点数相当不准确, 例如下面的代码: 复制代码代码如下: #!/usr/bin/env python import json a ...

  2. PHPStorm 3.0 与服务器端代码同步配置

    首先打开PhpStrom->Toolbar->Settings(工具栏的倒数第三行) 进入Settings后的界面如下 单击进入左边Deployment目录,在右边配置信息里面进行配置 填 ...

  3. POJ 2568/ZOJ 1965 Decode the Tree

    题意:在树中,每次删去节点值最小的叶子结点. 每删去一个点,就给出与这相连的点的值,直到最后只剩下一个根结点,给这N-1个数,重新建立这个树. 思路: 给出的节点号按次序存入到数组a中,将未给出的数存 ...

  4. 1051 Wooden Sticks

    Wooden Sticks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  5. lintcode 中等题:Singleton number II 落单的数 II

    题目 落单的数 II 给出3*n + 1 个的数字,除其中一个数字之外其他每个数字均出现三次,找到这个数字. 样例 给出 [1,1,2,3,3,3,2,2,4,1] ,返回 4 挑战 一次遍历,常数级 ...

  6. 【nginx运维基础(5)】Nginx的location攻略

    概述 location 有"定位"的意思, 根据Uri来进行不同的定位. 在虚拟主机的配置中,是必不可少的,location可以把网站的不同部分,定位到不同的处理方式上.伪静态,反 ...

  7. 天气API整理,返回的数据格式为json对象

    中国天气的API惨遭封杀,不得已更换其他的API使用吧. 这里大部分API来自APP的数据包截取或者反汇编,所以各开发使用者不得用于商业用途,否则后果自负! 1.金山网址导航 来源:http://ww ...

  8. NSArray 利用数组创建数组

    NSArray *array=[NSArray arrayWithObjects:@"1",@"2",@"3", nil];         ...

  9. android休眠唤醒流程2

    android系统一段时间没有操作,    屏幕(screen)将从高亮(bright)变为暗淡(dim),如果再过段时间还是没有操作,屏幕(screen)从暗淡(dim)变为关闭(off).这时,系 ...

  10. 选择语句----switch case

    今天学习了选择语句的 switch case是多选一的情况可以使用. 案例: //分别输入月份 几号 输出是今年的多少天 //每年的1,3,5,7,8,10,12月是31天 //今年的2月是28天 其 ...