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 ...
随机推荐
- 关于百度 UEditor的使用
1.文件路径的配置: 注意:在页面上需要指定editor文件所在的路径,否则报错 后面有时间,再说说 kindEditor和 bootstrap3的summernote的 Editor, fck ...
- base64加密解密文件
1 //字符串加密 -(void)demo1 { //普通的 8 bit二进制数据 NSString *str = @"hello world!"; //将字符串转换成二进制数据 ...
- JavaScript 字符串(String) 对象
JavaScript 字符串(String) 对象 String 对象用于处理已有的字符块. JavaScript 字符串 一个字符串用于存储一系列字符就像 "John Doe". ...
- js 中读取JSON的方法探讨
方法一:函数构造定义法返回 var strJSON = "{name:'json name'}"; //得到的JSONvar obj = new Function("r ...
- mysql数据库中编码问题(续)
其实之前的数据库中文乱码问题并没有彻底的解决,虽然在网页上显示正常,但是在数据库中却是乱码,虽然用户看起来没问题,但是自己就遭罪了,而且也是个极大的问题 究其原因,是没注意到一点,就是数据库中表的结构 ...
- POJ 1286 Necklaces of Beads (Burnside定理,有限制型)
题目链接:http://vjudge.net/problem/viewProblem.action?id=11117 就是利用每种等价情形算出置换节之后算组合数 #include <stdio. ...
- SGU 101.Domino (欧拉路)
时间限制: 0.5 sec 空间限制: 4096 KB 描述 多米诺骨牌,一种用小的方的木块或其他材料,每个都被一些点在面上标记,这些木块通常被称为骨牌.每个骨牌的面都被一条线分成两个 方形,两边 ...
- overflow第一次觉得你有点可恶
今天用css做下拉菜单,因为不需要做手机自适应,再手机里看起来工整一点就行,可是列表中最后一个li的宽度撑开了父div,导致看起来很糟糕,所以给父元素加overflow:hidden:但是下拉列表也被 ...
- 通过C# 打开一个应用程序
System.Diagnostics.ProcessStartInfo Info = new System.Diagnostics.ProcessStartInfo(); //设置外部程序名 Info ...
- .NET Framework(二)
在上一篇的随笔中,我们在理论层面上大致说明了.NET Framework的工作机制,内容的确比较晦涩难懂,但是还是希望大家有时候可以看看.我个人觉得,编程不是一味的敲代码,当自己遇到瓶颈的时候,可以多 ...