Frogger(链式前向星+spfa小改动)

当 AI + 可视化融入消防:开启智能消防新时代 总结来说,AI + 可视化技术融入消防,开启了智能消防新时代。它以精准预警、高效救援和全面资源管理,革新消防工作方式。从前期规划到系统搭建,再到后期运维,每个环节都为提升消防能力奠定基础。尽管面临技术成本、数据安全和人员适应等挑战,但随着技术发展和应用推广,这些问题将逐步解决。相信在 AI + 可视化助力下,消防领域将不断进步,为人们创造更安全生活环境,有效抵御火灾威胁。 阅读详情

Description
Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sitting on another stone. He plans to visit her, but since the water is dirty and full of tourists’ sunscreen, he wants to avoid swimming and instead reach her by jumping.
Unfortunately Fiona’s stone is out of his jump range. Therefore Freddy considers to use other stones as intermediate stops and reach her by a sequence of several small jumps.
To execute a given sequence of jumps, a frog’s jump range obviously must be at least as long as the longest jump occuring in the sequence.
The frog distance (humans also call it minimax distance) between two stones therefore is defined as the minimum necessary jump range over all possible paths between the two stones.

You are given the coordinates of Freddy’s stone, Fiona’s stone and all other stones in the lake. Your job is to compute the frog distance between Freddy’s and Fiona’s stone.
Input
The input will contain one or more test cases. The first line of each test case will contain the number of stones n (2<=n<=200). The next n lines each contain two integers xi,yi (0 <= xi,yi <= 1000) representing the coordinates of stone #i. Stone #1 is Freddy’s stone, stone #2 is Fiona’s stone, the other n-2 stones are unoccupied. There’s a blank line following each test case. Input is terminated by a value of zero (0) for n.
Output
For each test case, print a line saying “Scenario #x” and a line saying “Frog Distance = y” where x is replaced by the test case number (they are numbered from 1) and y is replaced by the appropriate real number, printed to three decimals. Put a blank line after each test case, even after the last one.
Sample Input
2
0 0
3 4

3
17 4
19 4
18 5

0
Sample Output
Scenario #1
Frog Distance = 5.000

Scenario #2
Frog Distance = 1.414
一个青蛙从一个石头跳到目标石头,定义一条路的难度是这中间跳跃的最大距离,要求的是这些路线中,最大距离最小的那个。

其实就是把最短路比较中
d[v] = min(d[v],d[u] + w)改成d[v] = min(d[v],max(d[u],w));

#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = 1005;
int head[202],leap[202];
double d[202];
struct Node
{
    int x,y;
}node[202];
struct Edge
{
    int u,v,next;
    double w;
}edge[80005];
double dis(int a,int b)
{
    return sqrt(1.0*(node[a].x - node[b].x)*(node[a].x - node[b].x) + (node[a].y - node[b].y)*(node[a].y - node[b].y));
}
void add_edge(int u,int v,double w,int tot)
{
    edge[tot].u = u;edge[tot].v = v;
    edge[tot].w = w;
    edge[tot].next = head[u];
    head[u] = tot;
}
int main()
{
    #ifdef LOCAL
    freopen("C:\\Users\\巍巍\\Desktop\\in.txt","r",stdin);
    //freopen("C:\\Users\\巍巍\\Desktop\\out.txt","w",stdout);
    #endif // LOCAL
    int n,kase = 1;
    while(scanf("%d",&n) != EOF)
    {
        if(n == 0)break;
        for(int i = 1;i <= n;i++)
            scanf("%d%d",&node[i].x,&node[i].y);
        for(int i = 1;i <= n;i++)head[i] = -1;
        int tot = 1;
        for(int i = 1;i < n;i++)
        {
            for(int j = i + 1;j <= n;j++)
            {
                double d = dis(i,j);
                add_edge(i,j,d,tot++);
                add_edge(j,i,d,tot++);
            }
        }
        for(int i = 1;i <= n;i++)d[i] = inf;
        for(int i = 1;i <= n;i++)leap[i] = 0;
        queue<int>p;
        p.push(1);
        leap[1] = 1;d[1] = 0;
        while(p.size())
        {
            int u = p.front();p.pop();
            leap[u] = 0;
            for(int i = head[u];i != -1;i = edge[i].next)
            {
                int e = edge[i].v;
                double temp = max(edge[i].w,d[u]);
                if(d[e] > temp)
                {
                    d[e] = temp;
                    if(!leap[e])
                    {
                        leap[e] = 1;
                        p.push(e);
                    }
                }
            }
        }
        printf("Scenario #%d\n",kase++);
        printf("Frog Distance = %.3lf\n\n",d[2]);
    }
    return 0;
}
用Python玩转共现分析:从NLTK到热力图可视化(附完整代码) 本文详细介绍了如何使用Python进行文本共现分析,从NLTK基础文本处理到构建共现矩阵,并实现热力图可视化。通过完整的代码示例,帮助数据分析师和开发者掌握这一揭示词语间关联网络的实用NLP技术,快速从文本中提取语义关系和主题结构。 阅读详情

相关推荐

iPhone用户必看:不装App也能搞定GitHub 2FA验证的3种方法(附恢复码管理技巧)

本文为iPhone用户提供了无需安装第三方App即可完成GitHub双重身份验证(2FA)的三种原生方案:利用相机扫码与iCloud钥匙串自动填充、使用iCloud钥匙串内置的TOTP验证码生成器,以及借助Safari浏览器扩展。文章详细解析了每种方法的操作步骤、适用场景,并重点强调了恢复码的安全管理与多层备份策略,帮助开发者在提升账户安全的同时,享受苹果生态的无缝便捷体验。

weixin_29324401的博客 653

Frogger POJ - 2253(spfa)

Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sitting on another stone. He plans to visit her, but since the water is dirty and full of tourists’ sun...

starlet_kiss的博客 203

Stata做DID平行趋势检验,用coefplot画图时遇到的3个坑及解决办法

本文详细解析了使用Stata进行DID平行趋势检验时,利用coefplot绘图可能遇到的三个常见问题及其解决方案。包括基线期选择陷阱、置信区间变形和图形元素错位,提供专业调试步骤和高阶技巧,帮助研究者高效完成学术级图表绘制。

weixin_42530458的博客 324

poj 2253 Frogger 【spfa跑一遍】

题目链接:http://poj.org/problem?id=2253 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 60900   Accepted: 19052 Description Freddy Frog is sitting on a stone in the middle o...

甜晨流年 308

别再被无限debugger卡住了!Chrome DevTools实战绕过技巧(含Hook与文件替换)

本文详细介绍了如何通过Chrome DevTools绕过无限debugger封锁的实战技巧,包括Hook技术与文件替换方法。针对常见的定时器轰炸、循环陷阱和动态注入等反调试手段,提供了高效的解决方案,帮助开发者快速突破调试障碍,提升爬虫和逆向工程效率。

weixin_30326515的博客 241

别再只用相机标定了!手把手教你用OpenCV和Python搞定投影仪标定(附完整代码)

本文详细介绍了如何使用Python和OpenCV实现投影仪标定,特别针对结构光三维扫描中的核心问题。通过低成本替代方案和优化算法,解决投影仪标定中的非线性畸变和亮度-距离耦合效应,显著提升三维重建精度。附完整代码和实战技巧,帮助开发者快速掌握关键技术。

weixin_29274337的博客 541

POJ2253 Frogger(最短路变形,floyd,Dijkstra,spfa)

题目: Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 40328   Accepted: 12960 Description Freddy Frog is sitting on a stone in the middle

riba2534的博客 6789

大疆mini 3 pro rtmp推流(带屏遥控器不支持)windows

大疆mini 3 pro无人机rtmp推流(带屏遥控器不支持)至windows电脑

xbsigeibwkouvfcj的博客 3430

poj 2253 Frogger (spfa) (Floyd)

http://poj.org/problem?id=2253 Frogger Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Description Freddy Frog is sitting on a s

大太阳 829

基于4G cat.1的低功耗车牌识别摄像头模组介绍

在消费类摄像头领域,4G低功耗相机已经非常普遍,在可视门锁,婴儿看护,户外监控等领域都获得了很好的应用.但是在工业领域,低功耗相机的应用还不是那么广泛.这里要介绍一款基于4G cat.1的低功耗车牌识别摄像头模组,在待机状态只有MCU和毫米波雷达以1Hz的频率工作,功耗低至500uA,并可以通过4G模块远程唤醒模组.

bindaz的专栏 1647

Linux与Windows双系统,安装完linux后无法通过grub进入Windows的解决方法

先装Windows 10,Windows可正常启动,再装Kali,Kali提示装grub后照装。然而装完后重启发现无Windows选项。

sakurashockwave的博客 6454

B - Frogger (青蛙路径-SPFA)

B - Frogger     思路: 复制一下别人的题意,有两只青蛙和若干块石头,现在已知这些东西的坐标,两只青蛙A坐标和青蛙B坐标是第一个和第二个坐标,现在A青蛙想要到B青蛙那里去,并且A青蛙可以借助任意石头的跳跃,而从A到B有若干通路,问从A到B的所有通路上的最大边,比如有  有两条通路  1(4)5 (3)2 代表1到5之间的边为4,  5到2之间的边为3,那么该条通路跳跃范围(两...

BePosit的博客 1734

高创伺服的龙门调试经历2

摘要:本文介绍了高创伺服在龙门控制中的配置方法。首先通过ServoStudio2连接驱动器并命名区分主从轴(MASTER/DIFF),然后设置接口模式、23位编码器参数及极限位置。重点说明龙门模式的三项关键参数设置(gantryfbenmode=1、gantrymode=1/2)和连线状态确认。建议单轴自动整定后调整从轴增益(如0.2),并强调带刹车电机的同步控制要点:刹车线需接同一继电器由主轴控制,避免位置偏差。

wzz418550729的博客 908

poj2253Frogger 最短路水题

//一个无向图,求从起点到终点的所经过的路径中的最大值最小 //最短路,更新的时候dis[i] = min(dis[i] , max(dis[u] , map[u][i])); #include<cstdio> #include<cstring> #include<iostream> #include<queue> #include<cmath> using namespace std ; cons

ijbuhv的专栏 1124

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

0 or 1(最短路转化)

Description Given a n*n matrix C ij (1<=i,j<=n),We want to find a n*n matrix X ij (1<=i,j<=n),which is 0 or 1. Besides,X ij meets the following conditions: 1.X 12+X 13+…X 1n=1 2.X 1n+X 2n+…X n-1n=1

Techay的博客 1101

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

Tram(转换为最短路模型)

Description Tram network in Zagreb consists of a number of intersections and rails connecting some of them. In every intersection there is a switch pointing to the one of the rails going out of the in

Techay的博客 750

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

Invitation Cards(最短路)

Description In the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want to propagate theater and, most of all, Antique Com

Techay的博客 733

Heavy Transportation(最短路变形)

Description Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there really is a way from the

Techay的博客 714

The Shortest Path in Nya Graph(神一样的建图)

Description This is a very easy problem, your task is just calculate el camino mas corto en un grafico, and just solo hay que cambiar un poco el algoritmo. If you do not understand a word of this para

Techay的博客 687

Layout(差束约分系统)

Description Like everyone else, cows like to stand close to their friends when queuing for feed. FJ has N (2 <= N <= 1,000) cows numbered 1..N standing along a straight line waiting for feed. The cows

Techay的博客 686

Candies(差数约分系统-最短路)

During the kindergarten days, flymouse was the monitor of his class. Occasionally the head-teacher brought the kids of flymouse’s class a large bag of candies and had flymouse distribute them. All the

Techay的博客 675

Silver Cow Party(边取反最短路)

Description One cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1..N is going to attend the big cow party to be held at farm #X (1 ≤ X ≤ N). A total of M (1 ≤ M ≤ 100,000) unidirectional

Techay的博客 673

昂贵的聘礼(坑爹的枚举+bellmanford)

Description 年轻的探险家来到了一个印第安部落里。在那里他和酋长的女儿相爱了,于是便向酋长去求亲。酋长要他用10000个金币作为聘礼才答应把女儿嫁给他。探险家拿不出这么多金币,便请求酋长降低要求。酋长说:”嗯,如果你能够替我弄到大祭司的皮袄,我可以只要8000金币。如果你能够弄来他的水晶球,那么只要5000金币就行了。”探险家就跑到大祭司那里,向他要求皮袄或水晶球,大祭司要他用金币来换,

Techay的博客 660

Extended Traffic(spfa判负环)

Description Dhaka city is getting crowded and noisy day by day. Certain roads always remain blocked in congestion. In order to convince people avoid shortest routes, and hence the crowded roads, to re

Techay的博客 613

Arbitrage(bellman-Ford)

Description Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currency. For example, suppose that 1 US Dollar buy

Techay的博客 598

Currency Exchange(bellman-Ford)

Description Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations only with these currencie

Techay的博客 480
上一篇: Til the Cows Come Home(链式前向星+spfa)
下一篇: Heavy Transportation(最短路变形)
Techay
博客等级 码龄11年 11粉丝 174原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值