题意

给你n个点,1为起点,2为终点,要求所有1到2所有路径中每条路径上最大值的最小值。


思路

不想打最短路
跑一边最小生成树,再扫一遍1到2的路径,取最大值即可

注意g++要用%f输出!!!


常数巨大的丑陋代码

# include <stdio.h>
# include <stdlib.h>
# include <iostream>
# include <string.h>
# include <math.h>
# include <algorithm>
using namespace std; # define IL inline
# define RG register
# define UN unsigned
# define ll long long
# define rep(i, a, b) for(RG int i = a; i <= b; i++)
# define per(i, a, b) for(RG int i = b; i >= a; i--)
# define uev(e, u) for(RG int e = ft[u]; e != -1; e = edge[e].nt)
# define mem(a, b) memset(a, b, sizeof(a))
# define max(a, b) (((a) > (b)) ? (a) : (b))
# define min(a, b) (((a) < (b)) ? (a) : (b))
# define Swap(a, b) a ^= b, b ^= a, a ^= b;
# define Sqr(a) ((a) * (a)) IL ll Get(){
RG char c = '!'; RG ll x = 0, z = 1;
while(c != '-' && (c < '0' || c > '9')) c = getchar();
if(c == '-') z = -1, c = getchar();
while(c >= '0' && c <= '9') x = x*10+c-'0', c = getchar();
return x*z;
} const int MAXN = 1000001;
int ft[MAXN], n, cnt, vis[MAXN], fa[MAXN], m;
struct Edge{
int to, nt;
double f;
} edge[MAXN<<1];
struct _Edge{
int u, v;
double f;
IL bool operator < (_Edge b) const{
return f < b.f;
}
} _edge[MAXN];
double ans, x[MAXN], y[MAXN]; IL void Add(RG int u, RG int v, RG double f){
edge[cnt] = (Edge){v, ft[u], f}; ft[u] = cnt++;
} IL int Find(RG int x){
return fa[x] == x ? x : Find(fa[x]);
} IL void Kruskal(){
sort(_edge + 1, _edge + m + 1);
RG int t = 0;
rep(i, 1, m){
if(t == n - 1) break;
RG int u = Find(_edge[i].u), v = Find(_edge[i].v);
if(u != v){
t++; fa[u] = v;
Add(u, v, _edge[i].f); Add(v, u, _edge[i].f);
}
}
} IL void Dfs(RG int u, RG double ans1){
if(u == 2) ans = ans1;
uev(e, u){
RG int v = edge[e].to;
if(vis[v]) continue;
vis[v] = 1;
RG double f = max(ans1, edge[e].f);
Dfs(v, f);
}
} int main(){
RG int T = 0;
n = Get();
while(n){
T++;
mem(ft, -1); m = ans = cnt = 0;
rep(i, 1, n) scanf("%lf%lf", &x[i], &y[i]);
rep(i, 1, n-1) rep(j, i+1, n){
double dis = sqrt(Sqr(x[i] - x[j]) + Sqr(y[i] - y[j]));
_edge[++m] = (_Edge){i, j, dis};
}
rep(i, 1, n) fa[i] = i;
Kruskal();
mem(vis, 0); vis[1] = 1;
Dfs(1, 0);
printf("Scenario #%d\nFrog Distance = %.3f\n\n", T, ans);
n = Get();
}
return 0;
}

Frogger POJ - 2253的更多相关文章

  1. floyd类型题UVa-10099-The Tourist Guide +Frogger POJ - 2253

    The Tourist Guide Mr. G. works as a tourist guide. His current assignment is to take some tourists f ...

  2. Frogger POJ - 2253(求两个石头之间”所有通路中最长边中“的最小边)

    题意 ​ 题目主要说的是,有两只青蛙,在两个石头上,他们之间也有一些石头,一只青蛙要想到达另一只青蛙所在地方,必须跳在石头上.题目中给出了两只青蛙的初始位置,以及剩余石头的位置,问一只青蛙到达另一只青 ...

  3. Frogger - poj 2253 (Dijkstra)

      Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 28802   Accepted: 9353 Description Fr ...

  4. kuangbin专题专题四 Frogger POJ - 2253

    题目链接:https://vjudge.net/problem/POJ-2253 思路: 从一号到二号石头的所有路线中,每条路线中都个子选出该路线中两点通路的最长距离,并在这些选出的最长距离选出最短路 ...

  5. 最短路(Floyd_Warshall) POJ 2253 Frogger

    题目传送门 /* 最短路:Floyd算法模板题 */ #include <cstdio> #include <iostream> #include <algorithm& ...

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

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

  7. POJ. 2253 Frogger (Dijkstra )

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

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

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

  9. POJ 2253 Frogger(dijkstra 最短路

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

随机推荐

  1. Linux下配置APACHE支持PHP环境

    编辑 /usr/local/apache2/conf/httpd.conf 文件时要注意: 找到: AddType application/x-compress .Z AddType applicat ...

  2. mysqldump 备份导出数据排除某张表

    就用 --ignore-table=dbname.tablename参数就行,可以忽略多个. /usr/bin/mysqldump -- -uroot -p123456 dbname --ignore ...

  3. hdu4149 Magic Potion

    Magic Potion Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Tota ...

  4. 数组的toString方法

    数组继承了object类的toString方法,数据类型将按照旧的格式打印,例如: int[] luckyNumbers = {2,3,5,7,11,13}; String s = "&qu ...

  5. 【Javascript】在文本框光标处插入文字并定位光标 (转)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  6. ubuntu17 安装中文输入法

    在此说的是intelligent pinyin.我首先尝试的是搜狗输入法,虽然最终安装成功了,但还是直接卸载了.因为它不仅需要fcitx框架,在安装成功后,标题栏上面还会出现两个输入法图标.真正不能让 ...

  7. python中 字符 字典 列表之间的转换

    1 字典 转 字符 定义一个字典:dict = {'name': 'python', 'age': 7}字典转字符 可以使用str强制转换 如: str(dict) 此时dict的类型就是字符型了 2 ...

  8. MAC地址表配置与绑定

    MAC地址表分类 ---静态MAC地址表项由用户手工配置,表项不老化: ---黑洞MAC地址表项包括源黑洞MAC地址表项和目的黑洞MAC地址表项,用于丢弃含有特定源MAC地址或目的MAC地址的报文(例 ...

  9. web工程导入新环境的注意事项

    问题一:The type java.lang.Object cannot be resolved. 解决办法: 当你在Eclipse引用不同版本JDK工程时会发生该问题.由于你开发环境中应用了多个版本 ...

  10. 如何在模拟器里体验微软HoloLens

    众所周知,微软的HoloLens以及MR设备售价都比较高,这让不少感兴趣的朋友们望而却步,本篇教程将向大家介绍如何在模拟器里体验传说中的HoloLens. 1.需要准备的硬件: 智能手机一台(WP.A ...