Frogger
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 39453   Accepted: 12691

Description

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 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
#include<iostream>
#include<cstdio>
#include<cmath>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
typedef __int64 LL;
const int maxn = 205;
const int INF = 0x3f3f3f3f;
struct Edge{
	int u,v,w,next;
	bool operator < (const Edge &a)const
	{
		return w > a.w;
	}
}edge[maxn*maxn<<1];

struct Point{
	int x,y;
}point[maxn];

int tot = 0,head[maxn],dis[maxn];
bool vis[maxn];

double dist(int x1,int y1,int x2,int y2)
{
	return (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);
}

void addedge(int u,int v,int w)
{
	edge[tot] = (Edge){u,v,w,head[u]
	};
	head[u] = tot++;
}

void dijkstra()
{
	priority_queue<Edge>que;
	memset(dis,INF,sizeof(dis));
	memset(vis,false,sizeof(vis));
	Edge p;
	p.v = 1;
	que.push(p);
	dis[1] = 0;
	while (!que.empty())
	{
		p = que.top();
		que.pop();
		int u = p.v;
		if (vis[u])	continue;
		vis[u] = true;
		for (int i = head[u]; ~i;i = edge[i].next)
		{
			int w = max(edge[i].w,dis[u]);
			int v = edge[i].v;
			if (dis[v] > w)
			{
				dis[v] = w;
				p.u = u,p.v = v,p.w = w;
				que.push(p);
			}
		}
	}
}

int main()
{
	//freopen("input.txt","r",stdin);
	int N,tcase = 1;
	while (~scanf("%d",&N) && N)
	{
		memset(head,-1,sizeof(head));
		tot = 0;
		for (int i = 0;i < N;i++)	scanf("%d%d",&point[i].x,&point[i].y);
		for (int i = 0;i < N;i++)
		{
			for (int j = 0;j < N;j++)
			{
				int diss = dist(point[i].x,point[i].y,point[j].x,point[j].y);
				addedge(i + 1,j + 1,diss);
				addedge(j + 1,i + 1,diss);
			}
		}
		dijkstra();
		double res = sqrt(dis[2]);
		printf("Scenario #%d\n",tcase++);
		printf("Frog Distance = %.3f\n\n",res);
	}
	return 0;
}

  

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

  1. POJ. 2253 Frogger (Dijkstra )

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

  2. POJ 2253 Frogger(dijkstra 最短路

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

  3. poj 2253 Frogger (dijkstra最短路)

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

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

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

  5. POJ 2253 Frogger(dijkstra变形)

    http://poj.org/problem?id=2253 题意: 有两只青蛙A和B,现在青蛙A要跳到青蛙B的石头上,中间有许多石头可以让青蛙A弹跳.给出所有石头的坐标点,求出在所有通路中青蛙需要跳 ...

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

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

  7. POJ 2253 Frogger (dijkstra 最大边最小)

    Til the Cows Come Home 题目链接: http://acm.hust.edu.cn/vjudge/contest/66569#problem/A Description The i ...

  8. POJ 2253 Frogger (Dijkstra变型)

    题意:求点1到点2的路径中,权值最大的那条边,其最小值是多少. 分析:最大值最小化.可以将迪杰斯特拉模板中的松弛操作加以修改,在O(n^2)的时间内解决该问题.其中需要注意的是,dist[i]指的是: ...

  9. POJ - 2253 Frogger(最短路Dijkstra or flod)

    题意:要从起点的石头跳到终点的石头,设The frog distance为从起点到终点的某一路径中两点间距离的最大值,问在从起点到终点的所有路径中The frog distance的最小值为多少. 分 ...

随机推荐

  1. jquery的选择器

    一.基本选择器 1.$("#id") id选择器,返回单个元素 2.$(".class") class选择器,返回集合元素 3.$("element& ...

  2. 【IOS开发笔记03-视图相关】简单计算器的实现

    UIView 经过前几天的快速学习,我们初步了解的IOS开发的一些知识,中间因为拉的太急,忽略了很多基础知识点,这些知识点单独拿出来学习太过枯燥,我们在今后的项目中再逐步补齐,今天我们来学习APP视图 ...

  3. 案例借鉴 | 某通讯巨头的IT建设方案

    成都联通作为合并重组后的中国联通在成都的分支机构,拥有基础扎实的通信网络和当前最先进技术的WCDMA网络.随着3G和4G业务的发展领先,成都联通凭借其出色的网络能力和服务,在用户中赢得了口碑. 在IT ...

  4. Undefined symbols for architecture arm64:

    1. 没有往项目中导入静态库(.a 文件)需要的 framework. 2.拖到项目中的静态库不支持arm64(或其他)指令集  这种情况没遇到过 一般都是第一种情况.

  5. win7的6个网络命令

    1 名称: Ipconfig 参数: /all : 显示详细信息 /renew: 更新所有适配器 /renew EL*:更新所有名称以EL为开头的连接 /release *Con*: 释放所有匹配的连 ...

  6. 容易忘记的git命令

    pwd命令:显示当前的目录 git init:把当前目录变成git可以管理的仓库 git diff 文件名:查看修改了什么内容 git log:查看commit历史,包括时间.作者.版本号.commi ...

  7. 动态调用WebService

    WebService内容 using Microsoft.CSharp;using System;using System.CodeDom;using System.CodeDom.Compiler; ...

  8. 如何在mac上用终端打开XAMPP自带的MySQL

    注:1.本文未经博主同意,不得转载! 2.所有终端语句都分行显示,以免大家看错: 直接开始,过程中对每一步可能出现的错误都进行了说明. 1.安装好xampp,然后打开终端,输入: mysql -u r ...

  9. kvm常用操作

    安装一些虚拟化的组件 yum -y install kvm python-virtinst libvirt bridge-utils virt-manager qemu-kvm-tools virt- ...

  10. Windows 10不能拨L2TP协议的VPN

    之前是Windows 10版本1607版本14393.102升级14393.187过后,突然出现不能拨公司防火墙的L2TPVPN了. 网上众说纷纭,原来遇到这个问题的人真不少,不过我是第一次遇到.结合 ...