POJ 3669 Meteor Shower

【题解】POJ 3669 Meteor Shower(BFS) POJ 3669 Meteor Shower https://vjudge.net/problem/POJ-3669 题意 有一场流星雨即将到来,Bessie要找到一个安全的地方。现在已知有M颗流星,并且知道它们抵达的位置和时间,Bessi走一个单位需要一个单位时间,问到达安全位置的最短时间,如果无法到达安全位置就输出-1。 细则: 1、Bessie从起点出发,可以向上下左右四个方向行走。 ... 阅读详情

POJ 3669 Meteor Shower

题目链接

Description

Bessie hears that an extraordinary meteor shower is coming; reports say that these meteors will crash into earth and destroy anything they hit. Anxious for her safety, she vows to find her way to a safe location (one that is never destroyed by a meteor) . She is currently grazing at the origin in the coordinate plane and wants to move to a new, safer location while avoiding being destroyed by meteors along her way.

The reports say that M meteors (1 ≤ M ≤ 50,000) will strike, with meteor i will striking point (Xi, Yi) (0 ≤ Xi ≤ 300; 0 ≤ Yi ≤ 300) at time Ti (0 ≤ Ti ≤ 1,000). Each meteor destroys the point that it strikes and also the four rectilinearly adjacent lattice points.

Bessie leaves the origin at time 0 and can travel in the first quadrant and parallel to the axes at the rate of one distance unit per second to any of the (often 4) adjacent rectilinear points that are not yet destroyed by a meteor. She cannot be located on a point at any time greater than or equal to the time it is destroyed).

Determine the minimum time it takes Bessie to get to a safe place.

Input

  • Line 1: A single integer: M
  • Lines 2..M+1: Line i+1 contains three space-separated integers: Xi, Yi, and Ti

Output

  • Line 1: The minimum time it takes Bessie to get to a safe place or -1 if it is impossible.

Sample Input

4
0 0 2
2 1 2
1 1 2
0 3 5

Sample Output

5

分析

广度优先搜索BFS。BFS模板利用队列完成。main()函数中对数据做了预处理。

源代码

#include<iostream>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
int visit[1000][1000];
int dx[5]={-1,0,0,0,1};
int dy[5]={0,1,0,-1,0};
struct point{
    int x,y;
    int step;
};
queue<point> que;
int bfs(){
    if(visit[0][0]==0) return -1;
    if(visit[0][0]==-1) return 0;
    point s,cur,next;
    s.x=0;//起点
    s.y=0;
    s.step=0;
    que.push(s);
    while(que.size()){
        cur=que.front();
        que.pop();
        for(int i=0;i<5;i++){
            next.x=cur.x+dx[i];
            next.y=cur.y+dy[i];
            next.step=cur.step+1;

            if(next.x>=0 && next.y>=0 && next.x<1000 && next.y<1000){
                if(visit[next.x][next.y]==-1){
                    return next.step;
                }
                if(next.step<visit[next.x][next.y]){
                    visit[next.x][next.y]=next.step;
                    que.push(next);
                }
            }

        }
    }
    return -1;
}

int main(){
    int M,x,y,t,xx,yy;
    cin>>M;
    memset(visit,-1,sizeof(visit));
    for(int i=0;i<M;i++){
        cin>>x>>y>>t;
        for(int j=0;j<5;j++){
            xx=x+dx[j];
            yy=y+dy[j];
            if(xx>=0 && yy>=0 && xx<1000 && yy<1000){
                if(visit[xx][yy]==-1){
                    visit[xx][yy]=t;
                }
                else{
                    visit[xx][yy]=min(visit[xx][yy],t);
                }
            }
        }
    }
    int result=bfs();
    cout<<result<<endl;
    return 0;  
}
Kimodo 入门教程(一)英伟达开源人形机器人动捕数据集训练运动学动作扩散模型 Kimodo是一个基于700小时商用光学动作捕捉数据集训练的运动学动作扩散模型,能够生成高质量的人体和机器人3D动作。该模型支持通过文本提示和多种约束条件(如关键帧、末端执行器位置等)进行控制,并提供数字人类和类人机器人两种模型变体。安装方式包括软件包安装和源代码安装两种,需要配置HuggingFace令牌以访问文本编码器。推荐使用GPU加速,最低需要17GB显存。项目提供命令行生成和交互式演示两种使用方式,演示程序支持时间轴编辑和实时3D可视化。模型分为商用友好版和受限版,其中SMPL-X版本需要额外申请 阅读详情

相关推荐

k8s部署 普罗米修斯(Prometheus)监控

Prometheus是一个开源的服务监控系统和时序数据库其提供了通用的数据模型和快捷数据采集、存储和查询接口它的核心组件Prometheus服务器定期从静态配置的监控目标或者基于服务发现自动配置的目标中进行拉 取数据新拉取到啊的 数据大于配置的内存缓存区时,数据就会持久化到存储设备当中。

D2961953033的博客 3855

P2895 [USACO08FEB]Meteor Shower S

在流星雨的田野里穿梭

qq_43034907的博客 700

数据仓库建模的步骤-从需求分析到模型优化的全面指南

数据仓库建模是一个系统化的过程,旨在设计和构建一个高效、可扩展的数据存储和分析环境。它的目标是将来自不同源系统的数据整合到一个统一的、面向主题的、随时间变化的数据集合中,以支持企业的决策制定过程。数据仓库建模不仅仅是创建表格和定义关系,它更是一门艺术,需要平衡业务需求、技术限制和未来的可扩展性。提供快速的查询性能支持复杂的分析需求适应业务的变化和增长保持数据的一致性和准确性接下来,让我们深入探讨数据仓库建模的每个主要步骤。

一个8年大数据开发工程师的碎碎念 2099

A - Meteor Shower的解答

A - Meteor Shower Bessie hears that an extraordinary meteor shower is coming; reports say that these meteors will crash into earth and destroy anything they hit. Anxious for her safety, she vows to fi...

Sunshine_H的帅气博客 466

保姆级教程:用YOLOv8/9/10搞定仪表盘指针识别,附完整数据集和Python环境配置

本文提供了一份基于YOLOv8/v9/v10的仪表盘指针检测全流程指南,涵盖环境配置、数据集构建、模型选型、训练调优和部署落地等关键步骤。通过详细的代码示例和实战经验,帮助开发者高效解决工业视觉中的仪表盘检测难题,特别适合电力巡检、智能监控等应用场景。

weixin_29031057的博客 1335

单细胞测序数据分析——细胞通讯 CellChat

cellchat

G2530051386的博客 1万+

每日一题4.14 P2895 [USACO08FEB]Meteor Shower

P2895 [USACO08FEB]Meteor Shower S 题目描述 Bessie hears that an extraordinary meteor shower is coming; reports say that these meteors will crash into earth and destroy anything they hit. Anxious for her s...

u014567353的博客 476

RAG面试内容整理-8. 文档分块策略(滑动窗口、语义切分)

RAG系统通常面对长文档或整篇知识库资料的检索需求,但大模型一次处理的文本长度有限,向量索引也需固定大小的文本片段。因此,将长文档拆分成合适片段是必不可少的步骤,被称为文档分块(chunking)策略。

不务正业的猿 690

BFS---陨石坠落

https://www.luogu.com.cn/problem/P2895 题目描述 Bessie hears that an extraordinary meteor shower is coming; reports say that these meteors will crash into earth and destroy anything they hit. Anxious for her safety, she vows to find her way to a safe locatio

zw201909250425的博客 443

ardupilot 日志分析《xKF1信息》

ardupilot 日志分析系列将会把ardupilot所有的日志文档进行分析,为我们分析无人机的运行状态,炸鸡原因,传感器状态,电机状态,控制信息,滤波信息做准备。本节主要分析xKF1日志信息,欢迎批评指正。学习好ardupilot必须会分析飞行日志,从飞行日志中我们可以学到很多无人机的知识。无人机是综合知识的体现,涵盖:导航、控制、滤波、算法、协议等各种知识,只有更全面的学习,才能在无人机的道路上越走越远。

陌城烟雨 1225

Flink 运维监控与指标采集实战(Prometheus + Grafana 全流程)

Flink运维监控在实时计算场景中至关重要,因为Flink作业需要7×24小时稳定运行,对性能、资源、故障感知和状态变化的实时监控是保障系统稳定的关键。Flink自带的Metrics系统提供了基本的监控能力,但为了更全面的监控,Prometheus+Grafana成为最主流的解决方案。通过配置PrometheusReporter和Grafana仪表盘,可以实现对Flink作业的全面监控,包括CPU、内存、吞吐量、Checkpoint状态、KafkaSink性能等关键指标。此外,自定义指标采集和报警机制的配置

晴天彩虹雨的博客 1368

POJ3669-Meteor Shower-BFS

原题链接 Meteor Shower Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 18098 Accepted: 4704 DescriptionBessie hears that an extraordinary meteor shower is coming; reports say tha

HowieMen的博客 400

【国产MCU】-认识CH32V307及开发环境搭建

CH32V307是[沁恒](https://www.wch.cn/)推出的一款基于32位RISC-V设计的互联型微控制器,配备了硬件堆栈区、快速中断入口,在标准RISC-V基础上大大提高了中断响应速度。加入单精度浮点指令集,扩充堆栈区,具有更高的运算性能。扩展串口UART数量到8组,电机定时器到4组。提供USB2.0高速接口(480Mbps)并内置了PHY收发器,以太网MAC升级到千兆并集成了10M-PHY模块。

视觉与物联智能 2343

【POJ3669】Meteor Shower 题解

http://poj.org/problem?id=3669 题意 有 MMM 个流星即将落到地球上。其中,第 iii 个会在 TiT_iTi​ 时落在 (Xi,Yi)(X_i, Y_i)(Xi​,Yi​) (0≤Xi,Yi≤300)(0\le X_i,Y_i \le 300)(0≤Xi​,Yi​≤300) 处,落地后,上下左右的四个格子也会被摧毁。 在第 000 秒,Bessie从原点处开始移动,她在第一象限中每秒移动一个坐标格,求什么时候可以到达安全的地方。 分析 BFS,普通的BFS判断能否转移时的条

weixin_47205053的博客 247

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

poj3669 Meteor Shower(BFS)

题目链接:poj3669 Meteor Shower 我只想说这题WA了后去看讨论才发现的坑点,除了要注意原点外,流星范围题目给的是[0,300],到302的位置就绝对安全了。。。 1 #include<cstdio> 2 #include<cmath> 3 #include<queue> 4 #include<cstr...

dhe56357的博客 256

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

【和小安一起刷题】POJ3669 Meteor Shower ----广度优先搜索(BFS)

01、题目描述 小伙伴们大家好,这里是和 【和小安一起刷题 】 系列栏目,今天我们要解决的是一道广搜题目——POJ3669 Meteor Shower。在解决题目前,你需要知道BFS的基本框架和C++< queue >库的简单使用。 题目链接: POJ3669 Meteor Shower. 题目描述:一场流星雨即将袭来,流星会对每个击中的地方以及其周围(上下左右四格)造成破坏。小明开始时位于(0, 0)位置,准备逃到一处不会被袭击到的地方(小明只能在第一象限内移动)。已知每移动1个单位长度需要1

一枝之栖 355

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

POJ3669-Meteor Shower

这是一道典型宽搜的题。 题目的注意点有很多: 300*300是流星的陨落范围,不是地图的大小。因此302是绝对的安全区域。 同一位置可能会有许多流星,这是应选择最早的那个进行状态标记。 t的范围是[0,1000],闭区间。所以存在刚开始就死在原点的可能性。(太惨了....) 同一队列中不同元素的时间可能是不同的,不能一概而论。 已访问过的点不必再访问。 #include #in

Collider 517

Poj3669 meteor shower bfs

题目链接:http://poj.org/problem?id=3669 题目大意:女主牛在起点(0,0),天气预报说今天会下流星雨,女主牛得逃生,流星砸下来它的附近的四个格点的位置都会被毁灭,以后不能再走,女主牛每次可走在地图范围内的四个格点,问女主牛至少得走多少歩才能安全。 分析:这个题目至少,明显是bfs,但又和以前的bfs不一样,唔。。。后来看了别人的结题报告才明白要自己够遭地图,先构建

Na_OH的博客 530

POJ3669 Meteor Shower

Description Bessie hears that an extraordinary meteor shower is coming; reports say that these meteors will crash into earth and destroy anything they hit. Anxious for her safety, she vows to find

sun_apple_123 335

POJ3669Meteor Shower【BFS】

Language: Default Meteor Shower Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11570   Accepted: 3163 Description Bessie hears that an extraordinary

走一步再走一步 770

Meteor Shower POJ - 3669

Meteor Shower POJ - 3669 Bessie hears that an extraordinary meteor shower is coming; reports say that these meteors will crash into earth and destroy anything they hit. Anxious for her safety, she vo...

Kobe_LBJ的博客 320

poj 3669 Meteor Shower

bfs。。.

GadyPu的专栏 414

poj-3669-Meteor Shower

题意:0- 思路:输入时先预处理,我定义一个结构体(包含vis检测是否有陨石掉在此格,time掉落时间),所以处理完之后,只需搜索vis为0即没有陨石掉落的地方即可。 代码附上:#include #include #include #include #include #include #include #define FIN freopen("input.txt","r",std

hm970928的博客 467
上一篇: POJ 3481 Double Queue
下一篇: 百练 1321: 棋盘问题
coding_sun
博客等级 码龄10年 10粉丝 56原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值