B - Frogger
#include<algorithm>
#include<queue>
#include<stdio.h>
#include<string.h>
#include<vector>
#include<math.h>
using namespace std; const int maxn = ;
const int oo = 0xfffffff; struct point{double x, y;}p[maxn];
struct node
{
int y;
double len;
node(int y, double len):y(y), len(len){}
};
vector<node> G[maxn];
double v[maxn]; //求两点间的距离
double Len(point a, point b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
void Spfa()
{
queue<int> Q;
Q.push(); while(Q.size())
{
int s = Q.front();Q.pop();
int len = G[s].size(); for(int i=; i<len; i++)
{
node q = G[s][i]; if(v[s] < v[q.y] && q.len < v[q.y])
{
v[q.y] = max(v[s], q.len);//要选取一条路上的最大的那条边
Q.push(q.y);
}
}
}
} int main()
{
int N, t=; while(scanf("%d", &N), N)
{
int i, j; for(i=; i<=N; i++)
scanf("%lf%lf", &p[i].x, &p[i].y); for(i=; i<=N; i++)
for(j=; j<=N; j++)
{
if(i == j)
continue; double len = Len(p[i], p[j]);
G[i].push_back(node(j, len));
} for(i=; i<=N; i++)
v[i] = oo;
v[] = ; Spfa(); if(t != )printf("\n");
printf("Scenario #%d\n", t++);
printf("Frog Distance = %.3f\n", v[]); for(i=; i<=N; i++)
G[i].clear();
} return ;
}
B - Frogger的更多相关文章
- POJ 2253 Frogger(Dijkstra)
传送门 Frogger Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 39453 Accepted: 12691 Des ...
- 2016HUAS_ACM暑假集训3B - Frogger
好几天没更新博客了,因为这周在看关于图论的算法,有好几个(还是英文名字-_-||),人晕晕的...... 说一下这个Frogger吧.这个题目的话......难的不是做法,而是题意... 大致题意:有 ...
- Frogger(floyd变形)
Frogger Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Stat ...
- 最小瓶颈路 Uva 534 Frogger
说明:关于Uva的题目,可以在vjudge上做的,不用到Uva(那个极其慢的)网站去做. 最小瓶颈路:找u到v的一条路径满足最大边权值尽量小 先求最小生成树,然后u到v的路径在树上是唯一的,答案就是这 ...
- POJ2253 Frogger
Frogger Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 34865 Accepted: 11192 Descrip ...
- poj2253 最短路 floyd Frogger
Frogger Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 28825 Accepted: 9359 Descript ...
- 最短路(Floyd_Warshall) POJ 2253 Frogger
题目传送门 /* 最短路:Floyd算法模板题 */ #include <cstdio> #include <iostream> #include <algorithm& ...
- POJ 2253 Frogger
题目链接:http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS Memory Limit: 65536K Total Submissi ...
- poj 2253 Frogger dijkstra算法实现
点击打开链接 Frogger Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 21653 Accepted: 7042 D ...
- POJ 2253 Frogger (最短路)
Frogger Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 28333 Accepted: 9208 Descript ...
随机推荐
- dnw for linux: Ubuntu下可用,无需编译驱动,mini2440可用
1.安装所需库文件 sudo apt-get install libusb-dev 2.源代码如下 /* dnw2 linux main file. This depends on libusb. * ...
- .net RAW(16)与GUID互相转换
.net 1.raw转guidnew guid(byte[] id);2.guid转rawGuid result;string ids = BitConverter.ToString(result.T ...
- 安卓学习之ListView和GridView
ListView 和 GridView是安卓中显示信息的两个很基本也最常用的控件.他们的用法很相似,但是他俩也是有区别的. ListView显示的数据会将他的item放在一行显示,而且根据内容给出it ...
- printf 缓冲区问题
突然发现printf的问题,看了这个很有意思,学习一下 转自:http://blog.csdn.net/shanshanpt/article/details/7385649 昨天在做Linux实验的时 ...
- 【HDU3802】【降幂大法+矩阵加速+特征方程】Ipad,IPhone
Problem Description In ACM_DIY, there is one master called “Lost”. As we know he is a “-2Dai”, which ...
- 一个基于nodejs,支持http/https的中间人(MITM)代理,便于渗透测试和开发调试。
源码地址:https://github.com/wuchangming/node-mitmproxy node-mitmproxy node-mitmproxy是一个基于nodejs,支持http/h ...
- Fatal error: Class 'ZipArchive' not found的解决办法
今天在Linux底下编写导出EXCEL文件并显示输出时,抛出“ZipArchive library is not enabled” 的异常.而我在本地的windows下的代码则是运行正常的. 原因是: ...
- php 详解spl_autoload_register()函数
在了解这个函数之前先来看另一个函数:__autoload. 一.__autoload 这是一个自动加载函数,在PHP5中,当我们实例化一个未定义的类时,就会触发此函数.看下面例子: printit.c ...
- NSNumber
integerfloatc 在Objective-c中有int的数据类型,那为什么还要使用数字对象NSNumber?这是因为很多类(如NSArray)都要求使用对象,而int不是对象.NSNumber ...
- iOS9 以上的真机调试 不用证书
具体流程如下: 首次使用AppleID 的注意事项: 要在设置中 进行 如下操作 设置--通用--描述文件 ---添加信任 但是有时候 还是 会不能调试, 显示信息 是这样的 : ...