题目传送门

 /*
最短路: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的更多相关文章

  1. [kuangbin带你飞]专题四 最短路练习 POJ 2253 Frogger

    求第一个点到第二个点的所有通路上最长的边 dijkstra的变形 每次松弛的是每条边通路上的的最长的边 WA了好几次是因为用了%lf 改成%f就过了…… /* ******************** ...

  2. POJ 2253 Frogger ,poj3660Cow Contest(判断绝对顺序)(最短路,floyed)

    POJ 2253 Frogger题目意思就是求所有路径中最大路径中的最小值. #include<iostream> #include<cstdio> #include<s ...

  3. POJ 2253 Frogger(dijkstra 最短路

    POJ 2253 Frogger Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fion ...

  4. POJ. 2253 Frogger (Dijkstra )

    POJ. 2253 Frogger (Dijkstra ) 题意分析 首先给出n个点的坐标,其中第一个点的坐标为青蛙1的坐标,第二个点的坐标为青蛙2的坐标.给出的n个点,两两双向互通,求出由1到2可行 ...

  5. poj 2253 Frogger (dijkstra最短路)

    题目链接:http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissi ...

  6. poj 2253 Frogger (最长路中的最短路)

    链接:poj 2253 题意:给出青蛙A,B和若干石头的坐标,现青蛙A想到青蛙B那,A可通过随意石头到达B, 问从A到B多条路径中的最长边中的最短距离 分析:这题是最短路的变形,曾经求的是路径总长的最 ...

  7. POJ 2253 ——Frogger——————【最短路、Dijkstra、最长边最小化】

    Frogger Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Stat ...

  8. poj 2253 Frogger 最小瓶颈路(变形的最小生成树 prim算法解决(需要很好的理解prim))

    传送门: http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissi ...

  9. POJ 2253 Frogger

    题目链接:http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissi ...

随机推荐

  1. 360双击ctrl搜索可能会与firefox快捷键冲突

    最近使用火狐浏览器时有好几次要在网页上的对话框输入文字时出现问题,按下字母键直接跳出了firefox菜单选项,用鼠标重新定位到输入位置再打还是不行,照样会弹出菜单提示,如下图,这可能是有什么快捷键冲突 ...

  2. CPU tick counter

    #define rdtscll(val) \ __asm__ __volatile__ ("rdtsc" : "=A" (val)) example #incl ...

  3. JQuery $(function(){})和$(document).ready(function(){})

    document.ready和onload的区别——JavaScript文档加载完成事件页面加载完成有两种事件一是ready,表示文档结构已经加载完成(不包含图片等非文字媒体文件)二是onload,指 ...

  4. js指定标签的id只能添加不能删除

    <body> <form id="form1" runat="server"> <div> <input id=&qu ...

  5. 反弹SHELL

    [姿势] http://www.91ri.org/6620.html http://www.waitalone.cn/linux-shell-rebound-under-way.html [图释] h ...

  6. Object-c 控制语句

    控制语句: 分支语句   if-else  有控制机制    switch 循环语句   while    do-while  for 跳转语句   break,continue,goto

  7. VS添加lib库

    #pragma comment(lib,"opengl32.lib")

  8. git merge和个git rebase的区别

    http://stackoverflow.com/questions/16666089/whats-the-difference-between-git-merge-and-git-rebase/16 ...

  9. August 1st, 2016, Week 32nd Monday

    Laughing is the most touching mask. 笑容是最动人的面具. I used to be very weclome in those I had met. And the ...

  10. 第一套增删改查(htm+ashx完成)

    1.展示人员列表htm文件: <a href="PersonEditAddNew.ashx?action=addnew">添加</a> </p> ...