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 ...
随机推荐
- CouchBase 遇到问题笔记(一)
刚开始看CouchBase,按照官网给出的示例,边敲边理解,遇到了一个很奇怪的问题,如下代码: IView<IViewRow> view = client.GetView("be ...
- 设置css三种方法的优先级
有的小伙伴问了,如果有一种情况:对于同一个元素我们同时用了三种方法设置css样式,那么哪种方法真正有效呢?在下面代码中就出现了这种情况 1.使用内联式CSS设置“超酷的互联网”文字为粉色. 2.然后使 ...
- ARM架构下linux设备树加载的方法
引入设备树后bootloader加载DTB方法: 1. 标准方法 将linux kernel放到内存地址为<kernel img addr>的内存中. 将DTB放到地址为<dtb a ...
- CentOS中vsftp安装、配置、卸载
1. 安装VSFTP 1 [root@localhost ~]# yum -y install vsftpd 2. 配置vsftpd.conf文件 [root@localhost ~]# vi /et ...
- Hdu 2874 Connections between cities
题意: 城市 道路 没有环 不一定连通的树 求两城市的最短距离 设想一下就是很多小树 那好办 思路: lca离线算法 然后有个技巧就是 每次我们tarjan一棵树不是最后树的节点都访问过并且孩子全 ...
- 一起来背ABC
construction 构造,结构 constructor 构造函数,施工员
- PHPCMS v9 自定义表单添加验证码验证
1. 在 \phpcms\templates\default\formguide\show.html 中添加验证码显示 <input type="text" id=" ...
- bom type:Phantom
bom的类型 'type': fields.selection([('normal','Normal BoM'),('phantom','Sets / Phantom')], 'BoM Type', ...
- centos下Elasticsearch数据迁移与备份
########### ### 共享创建es官方网站就一句话 ######## 1.下载 文件共享 .. rpm -i http://mirror.symnds.com/distributions ...
- 应用Oracle(Linux中的安装)
Linux中安装Oracle,不同于windows. Linux在安装时,要作些必要的分区配置,以便进行Oracle的安装: 同时需要创建专门的数据库用户和组,并配置环境变量. root登录 使用 r ...