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 ...
随机推荐
- Windows的计划任务
阅读目录 一:什么是Windows的计划任务? 二:如何设置计划任务 三:高级设置计划任务 一:什么是Windows的计划任务? 在日常的工作中,我们都有一些固定的或临时性的工作,而每次在爱机前一坐, ...
- IE浏览器设置
- iOS 使用 FFmpeg
iOS 使用 FFmpeg 字数486 阅读288 评论7 喜欢5 集成 下载FFmpeg For iOS编译脚本: 打开 terminal 执行sh build-ffmpeg.sh: 步骤2执行完成 ...
- 【POJ1195】【二维树状数组】Mobile phones
Description Suppose that the fourth generation mobile phone base stations in the Tampere area operat ...
- mysql 连接问题----转载
最近碰到一个mysql5数据库的问题.就是一个标准的servlet/tomcat网络应用,后台使用mysql数据库.问题是待机一晚上后,第二天早上第一次登录总是失败.察看日志发现如下错误: “com. ...
- truncate 命令删除恢复
truncate命令可以一次性删除当前表中所有记录并且不留任何日志,同时这个表的ID就自动初化从1开始,今天我就来给大家尝试一个利用truncate清除记录之后恢复过程. 实际线上的场景比较复杂,当时 ...
- PHP Mysql类【转】
前几天没事在网上转发现了一个类,记录下来: <?php Class DB { private $link_id; private $handle; private $is_log; privat ...
- C#【数据库】 Access类
using System; using System.Data; using System.Data.OleDb; namespace AccessDb { /**//// <summary&g ...
- Trigger model Trigger expr_id in WorkFolow
For example, suppose you want to set a Sale Order into the state "Done" once it has been s ...
- ECommon.Dapper
ECommon.Dapper 轻量级的dapper扩展 我们都知道Dapper这个orm框架,但是我们也知道他的扩展目前没有特别好的,今天我就推荐一个轻量级的很方便使用的一个扩展叫做 ECommon. ...