题目链接

题意:

从0号点,到1号点,找一条能通过的路,使得这条路中的最大的边,比其它所有可能的路中的边都小。

分析:

这题就是按着dijkstra写,写着写着觉得像是prim了。

其中d[n]表示从0出发到达该点的某条路中的最大边,且比其它可能的路中的都小。

从d[i]到d[j], 就是要用 max(d[i], G[i][j]) 去更新 d[j] 。

注意:

输出时要用 %.3f 不能用 %.3lf.

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <cmath> using namespace std; const int maxn = ; const double INF = 1e60; int n;
double G[maxn][maxn], d[maxn]; struct Pos {
int x, y;
}num[maxn]; double calc(int i, int j) {
return (sqrt(pow((double)num[i].x-num[j].x, )+pow((double)num[i].y-num[j].y, )));
} double dijkstra() {
bool vis[maxn]; memset(vis, false, sizeof(vis)); for(int i=; i<n; i++) {
d[i] = G[][i];
} d[] = ;
vis[] = true; for(int i=; i<n-; i++) {
double m = INF; int x;
for(int y=; y<n; y++) if(!vis[y] && m >= d[y]) m = d[x=y];
vis[x] = true;
for(int y=; y<n; y++){
if(!vis[y]) {
double maxx = max(d[x], G[x][y]);
if(d[y] > maxx) d[y] = maxx;
}
}
} return d[];
} int main() {
int cnt = ;
while(scanf("%d", &n) == ) {
if(n == ) break; for(int i=; i<n; i++) scanf("%d%d", &num[i].x, &num[i].y); for(int i=; i<n; i++) {
for(int j=; j<i; j++) {
G[i][j] = G[j][i] = calc(i, j);
}
G[i][i] = ;
} printf("Scenario #%d\nFrog Distance = %.3f\n\n", ++cnt, dijkstra());
} return ;
}

POJ2253 Frogger(最短路)的更多相关文章

  1. POJ2253 Frogger —— 最短路变形

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

  2. POJ2253 frogger 最短路 floyd

    #include<iostream>#include<algorithm>#include<stdio.h>#include<string.h>#inc ...

  3. POJ-2253 Frogger(最短路)

    https://vjudge.net/problem/POJ-2253 题意 公青蛙想到母青蛙那里去,期间有许多石头,公青蛙可以通过这些石头跳过去.问至少要跳的最大距离,即所有路径上石头间的最大距离的 ...

  4. POJ-2253.Frogger.(求每条路径中最大值的最小值,最短路变形)

    做到了这个题,感觉网上的博客是真的水,只有kuangbin大神一句话就点醒了我,所以我写这篇博客是为了让最短路的入门者尽快脱坑...... 本题思路:本题是最短路的变形,要求出最短路中的最大跳跃距离, ...

  5. poj2253 Frogger(最短路变型或者最小生成树)

    /* 题意:就是源点到终点有多条的路径,每一条路径中都有一段最大的距离! 求这些路径中最大距离的最小值! Dijkstra, Floyd, spfa都是可以的!只不过是将松弛的条件变一下就行了! 想了 ...

  6. Frogger(最短路)

    Frogger(poj2253) Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 31854   Accepted: 1026 ...

  7. poj2253 Frogger(Floyd)

    题目链接 http://poj.org/problem?id=2253 题意 给出青蛙A,B和若干石头的坐标,现在青蛙A要跳到青蛙B所在的石头上,求出所有路径中最远那一跳的最小值. 思路 Floyd算 ...

  8. POJ2253 Frogger

    Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 34865   Accepted: 11192 Descrip ...

  9. POJ 2253 Frogger (最短路)

    Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 28333   Accepted: 9208 Descript ...

随机推荐

  1. 山东省赛J题:Contest Print Server

    Description In ACM/ICPC on-site contests ,3 students share 1 computer,so you can print your source c ...

  2. 关于 Head First SQL 中文版

    我想谈谈 我对于Head  First  SQL  中文版的一些看法 事实上关于我翻译的这个Head  First  SQL 中文版..我自觉得:的确翻译得非常烂.. 和翻译Head  First  ...

  3. [PWA] 12. Intro to IndexedDB

    Use the library indexedDB-promised. Create a database and stroe: import idb from 'idb'; // Open(db_n ...

  4. Windows Minifilter驱动 - 调式 (4)

    写不论什么程序动态调试是很重要的.驱动开发也不例外. 通常如今写驱动的时候,都是在VM上跑的,调试手段基本也是本地windbg + 虚拟机. 虚拟机配置 我用的是win7, 第一步,看以下.成功运行后 ...

  5. Monitor and diagnose performance in Java SE 6--转载

    Java SE 6 provides an in-depth focus on performance, offering expanded tools for managing and monito ...

  6. C#操作INI配置文件示例

    源文件地址:http://pan.baidu.com/share/link?shareid=2536126078&uk=1761850335创建如图所示的控件: 源代码: using Syst ...

  7. Day1 - Python基础1 介绍、基本语法、流程控制

    Python之路,Day1 - Python基础1   本节内容 Python介绍 发展史 Python 2 or 3? 安装 Hello World程序 变量 用户输入 模块初识 .pyc是个什么鬼 ...

  8. noip 2012 借教室 (线段树 二分)

    /* 维护区间最小值 数据不超int 相反如果long long的话会有一组数据超时 无视掉 ll int */ #include<iostream> #include<cstdio ...

  9. win7 打开方式不能添加程序

    打开注册表,找到“HKEY_CLASSES_ROOT\Applications\”中,查看相应的程序的“\shell\open\command”项中的数据是否正确:如果不正确,就修改正确,之后再添加程 ...

  10. CSS控制表单

    一个简单的网站注册页面制作. 创建CSS文件如下: @charset "utf-8"; /* CSS Document */ * { margin: 0px; padding: 0 ...