最短路(Floyd_Warshall) POJ 2253 Frogger
/*
最短路:Floyd算法模板题
*/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
using namespace std; const int MAXN = + ;
const int INF = 0x3f3f3f3f;
double d[MAXN][MAXN];
int used[MAXN];
struct NODE
{
int x, y;
}node[MAXN]; double dis(int j, int i)
{
return sqrt ((node[j].x - node[i].x) * (node[j].x - node[i].x) + (node[j].y - node[i].y) * (node[j].y - node[i].y));
} void Floyd_Warshall(int n)
{
for (int k=; k<=n; ++k)
{
for (int i=; i<=n-; ++i)
{
for (int j=i+; j<=n; ++j)
{
if (d[i][k] < d[i][j] && d[k][j] < d[i][j])
{
if (d[i][k] < d[k][j])
d[i][j] = d[j][i] = d[k][j];
else
d[i][j] = d[j][i] = d[i][k];
}
}
}
} printf ("Frog Distance = %.3f\n", d[][]);
} int main(void) //POJ 2253 Frogger
{
//freopen ("D.in", "r", stdin); int n;
int cnt = ;
int first = ;
while (~scanf ("%d", &n) && n)
{
for (int i=; i<=n; ++i)
{
scanf ("%d%d", &node[i].x, &node[i].y);
}
for (int i=; i<=n-; ++i)
{
for (int j=i+; j<=n; ++j)
{
d[i][j] = d[j][i] = dis (i, j);
}
} printf ("Scenario #%d\n", ++cnt);
Floyd_Warshall (n);
puts ("");
} return ;
} /*
Scenario #1
Frog Distance = 5.000 Scenario #2
Frog Distance = 1.414
*/
最短路(Floyd_Warshall) POJ 2253 Frogger的更多相关文章
- [kuangbin带你飞]专题四 最短路练习 POJ 2253 Frogger
求第一个点到第二个点的所有通路上最长的边 dijkstra的变形 每次松弛的是每条边通路上的的最长的边 WA了好几次是因为用了%lf 改成%f就过了…… /* ******************** ...
- POJ 2253 Frogger ,poj3660Cow Contest(判断绝对顺序)(最短路,floyed)
POJ 2253 Frogger题目意思就是求所有路径中最大路径中的最小值. #include<iostream> #include<cstdio> #include<s ...
- POJ 2253 Frogger(dijkstra 最短路
POJ 2253 Frogger Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fion ...
- POJ. 2253 Frogger (Dijkstra )
POJ. 2253 Frogger (Dijkstra ) 题意分析 首先给出n个点的坐标,其中第一个点的坐标为青蛙1的坐标,第二个点的坐标为青蛙2的坐标.给出的n个点,两两双向互通,求出由1到2可行 ...
- poj 2253 Frogger (dijkstra最短路)
题目链接:http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS Memory Limit: 65536K Total Submissi ...
- poj 2253 Frogger (最长路中的最短路)
链接:poj 2253 题意:给出青蛙A,B和若干石头的坐标,现青蛙A想到青蛙B那,A可通过随意石头到达B, 问从A到B多条路径中的最长边中的最短距离 分析:这题是最短路的变形,曾经求的是路径总长的最 ...
- POJ 2253 ——Frogger——————【最短路、Dijkstra、最长边最小化】
Frogger Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Stat ...
- poj 2253 Frogger 最小瓶颈路(变形的最小生成树 prim算法解决(需要很好的理解prim))
传送门: http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS Memory Limit: 65536K Total Submissi ...
- POJ 2253 Frogger
题目链接:http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS Memory Limit: 65536K Total Submissi ...
随机推荐
- zoj.3865.Superbot(bfs + 多维dp)
Superbot Time Limit: 2 Seconds Memory Limit: 65536 KB Superbot is an interesting game which you ...
- poj1279.Inlay Cutters(模拟 + 枚举)
Inlay Cutters Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2367 Accepted: 995 Desc ...
- HDU 1707 简单模拟 Spring-outing Decision
Spring-outing Decision Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/O ...
- django revision
由于多次涉及到了这个东东,又不是很理解机制,决定深入研究下. what django-revision到底啥玩意?readthedocs上只有一句话概括:django-reversion can be ...
- [转]sql语句中出现笛卡尔乘积 SQL查询入门篇
本篇文章中,主要说明SQL中的各种连接以及使用范围,以及更进一步的解释关系代数法和关系演算法对在同一条查询的不同思路. 多表连接简介 在关系数据库中,一个查询往往会涉及多个表,因为很少有数据库只有一个 ...
- 【JavaScript】SVG vs Canvas vs WebGL
参考资料: http://blog.csdn.net/lufy_legend/article/details/38292125 http://zhidao.baidu.com/link?url=e4n ...
- Java RMI 框架
RMI(即Remote Method Invoke 远程方法调用).在Java中,只要一个类extends了java.rmi.Remote接口,即可成为存在于服务器端的远程对象,供客户端访问并提供一定 ...
- TCP/IP WebSocket MQTT
http://www.cnblogs.com/shanyou/p/4085802.html TCP/IP, WebSocket 和 MQTT
- soem函数库的编译
D:/并条机/soem/soem-master/doc/html/files.htm https://github.com/smits/soem https://github.com/OpenEthe ...
- codeigniter load_class
2014年7月7日 14:33:36 函数定义在 system/core/common.php中 使用方法是 load_class('Hooks', 'core'): 在core目录内寻找Hooks类 ...