POJ 2251 Dungeon Master ——————BFS

保姆级教程:用YOLOv8n模型在RKNN和Horizon平台完成目标检测(附C++部署代码与性能实测) 本文提供了一份详尽的YOLOv8n模型在RKNN和Horizon平台上的部署指南,涵盖环境配置、模型优化、跨平台适配及性能调优。通过实战案例和C++部署代码,帮助开发者在嵌入式设备上高效实现目标检测,显著提升推理性能。 阅读详情

Dungeon Master

Language:Default
Dungeon Master
Time Limit: 1000MSMemory Limit: 65536K
Total Submissions: 48826Accepted: 18436

Description

You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes one minute to move one unit north, south, east, west, up or down. You cannot move diagonally and the maze is surrounded by solid rock on all sides.

Is an escape possible? If yes, how long will it take?

Input

The input consists of a number of dungeons. Each dungeon description starts with a line containing three integers L, R and C (all limited to 30 in size).
L is the number of levels making up the dungeon.
R and C are the number of rows and columns making up the plan of each level.
Then there will follow L blocks of R lines each containing C characters. Each character describes one cell of the dungeon. A cell full of rock is indicated by a ‘#’ and empty cells are represented by a ‘.’. Your starting position is indicated by ‘S’ and the exit by the letter ‘E’. There’s a single blank line after each level. Input is terminated by three zeroes for L, R and C.

Output

Each maze generates one line of output. If it is possible to reach the exit, print a line of the form
Escaped in x minute(s).

where x is replaced by the shortest time it takes to escape.
If it is not possible to escape, print the line
Trapped!

Sample Input

3 4 5
S....
.###.
.##..
 ###.#

 #####
 #####
 ##.##
 ##...

 #####
 #####
 #.###
 ####E

1 3 3
S##
 #E#
 ###

0 0 0

Sample Output

Escaped in 11 minute(s).
Trapped!

Source

—– 虽然搜索的是三维的物体,但是是方向只有6个,也很简单。。。 没啥说的,一切尽在代码中 ——
#include<cstdio>
#include<cstring>
#include<queue>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN = 33;
char str[MAXN][MAXN][MAXN];
bool vis[MAXN][MAXN][MAXN];
int sx,sy,sz,L,R,C;
int d[6][3]={1,0,0, -1,0,0, 0,1,0, 0,-1,0, 0,0,1, 0,0,-1};
struct node{
    int x,y,z,step;
    node(){};
    node(int _x,int _y,int _z,int _step)
    {
        x=_x; y=_y; z=_z; step=_step;
    }
    bool operator < (const node &b)const
    {
       return step>b.step;
    }
};

int bfs(int x,int y,int z)
{
    memset(vis,0,sizeof(vis));
    vis[z][x][y]=1;
    int ans=-1;
    priority_queue<node>    que;
    que.push(node(x,y,z,0));
    node e1,e2;
    while(que.size())
    {
        e1=que.top();que.pop();
        if(str[e1.z][e1.x][e1.y]=='E')
        {
            ans=e1.step;
            break;
        }
        for(int i=0;i<6;i++)
        {
            e2.x=e1.x+d[i][0];
            e2.y=e1.y+d[i][1];
            e2.z=e1.z+d[i][2];
            e2.step=e1.step+1;
            if(!vis[e2.z][e2.x][e2.y] && str[e2.z][e2.x][e2.y]!='#' && 0 <= e2.z && e2.z < L && 0 <= e2.x && e2.x < R && 0 <= e2.y && e2.y < C)
            {
                vis[e2.z][e2.x][e2.y]=1;
                que.push(e2);
            }
        }
    }
    return ans;
}
int main()
{
    while(~scanf("%d %d %d",&L,&R,&C)&&(L|R|C))
    {
        for(int k=0;k<L;k++)
            for(int i=0;i<R;i++)
                scanf("%s",str[k][i]);
        int z=0;
        for(int k=0;k<L;k++)
        {
            if(z)   break;
            for(int i=0;i<R;i++)
            {
                if(z)   break;
                for(int j=0;j<C;j++)
                    if(str[k][i][j]=='S')
                    {
                        sx=i;
                        sy=j;
                        sz=k;
                        z=1;
                        break;
                    }
            }
        }
        int ans=bfs(sx,sy,sz);
        if(ans==-1)    puts("Trapped!");
        else           printf("Escaped in %d minute(s).\n",ans);
    }
    return 0;
}
SAP-ABAP:SAP的BAPI_GOODSMVT_CREATE 深度解析 BAPI_GOODSMVT_CREATE 深度解析** **功能定位**:SAP 标准接口,支持 **11 种库存移动场景**(收货/发货/转储/生产投料等),是 MM 模块集成核心 阅读详情

相关推荐

Docker一键部署Synopsys EDA全家桶(VCS/Verdi 2018版)保姆级教程

本文提供了一份详尽的Docker容器化部署Synopsys EDA工具链(VCS/Verdi 2018版)的保姆级教程。通过环境隔离与标准化,解决传统安装的依赖冲突问题,并重点攻克了容器内GUI图形界面显示的核心难题。教程涵盖从Docker基础安装、镜像获取、容器启动配置,到使用X11转发或VNC实现Verdi完美显示的完整实践,旨在帮助芯片设计工程师快速构建稳定、可移植的一键化EDA工作环境。

weixin_29281941的博客 198

三维bfs Dungeon Master POJ - 2251

三维bfs Dungeon Master POJ - 2251 题目链接 一直莫名其妙的错误 。。。 两种方法 一种用到队列 另一种其实也和队列差不多 不用队列 #include&lt;stdio.h&gt; #include&lt;string.h&gt; #include&lt;iostream&gt; #include&lt;queue&gt; using namespace std; ...

qq_43559193的博客 556

2021年J题:基于STM32F103的周期信号波形识别与参数测量系统设计(立创EDA+SZPT_ZXL)

本文详细复盘了2021年全国大学生电子设计竞赛J题获奖项目,手把手教你如何基于STM32F103微控制器设计并实现周期信号波形识别与参数测量系统。文章深入剖析了硬件电路设计(包括程控放大、工作点抬升与滞回比较器)与核心软件算法(如动态采样、FFT频谱分析与波形识别逻辑),并分享了DMA传输、FFT库使用等实战要点与避坑指南,为嵌入式信号处理与电赛备赛提供了宝贵经验。

weixin_32673065的博客 230

poj-2251 Dungeon Master【bfs】

很基础的一道bfs /*这题是一个三维的迷宫题目,其中用'.'表示空地,'#'表示障碍物,'S'表示起点,'E'表示终点, 求从起点到终点的最小移动次数,解法和二维的类似, 只是在行动时除了东南西北移动外还多了上下。 对于题目给出数据的含义就是输入l,r,c,分别代表迷宫有l层,每层长宽分别是c,r。 对于数据以可以这样移动 (1,1,1)->(1,1,2)->(1,1,3)->(1,1,4)-

a915800048的专栏 1400

关于 ABAP OPEN SQL 的动态 WHERE 条件和 Dynamic Selections

ABAP动态查询技术解析 本文介绍了ABAP中实现灵活数据库查询的动态选择技术,通过FREE_SELECTIONS函数组实现用户自定义查询条件。核心内容包括: 传统固定WHERE条件的局限性,无法满足业务多变需求 Dynamic Selections机制的工作原理,使用FREE_SELECTIONS_INIT初始化、FREE_SELECTIONS_DIALOG交互 完整Demo程序演示如何构建通用表数据浏览器: 用户输入表名后校验权限 调用动态选择函数生成条件 动态拼接WHERE子句执行查询 使用CL_SA

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 676

系统分析师论文范文(三)微服务

摘要(300字) 2024年4月,我作为系统分析师参与某省三甲医院云影像系统建设项目,负责系统分析与设计工作。该项目旨在响应国家"无胶片化"医疗政策,解决传统影像系统数据孤岛、调阅效率低等问题。系统基于DICOM 3.0和HL7国际标准,采用B/S架构与Spring Cloud Alibaba微服务技术栈,包含影像采集、智能分析、数据安全等核心模块,实现全院影像资源的云端统一管理与多端调阅。在架构设计上,通过微服务拆分、分布式事务控制及多层次安全防护机制,保障了系统的高可用性与数据一致性。系统于2024年1

echo的博客 221

POJ 2251(WA)Dungeon Master(三维BFS)

POJ 2251 Dungeon Master 三维简单BFS You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes one

No Rain,No L'Arc~en~Ciel 433

【DL经典回顾】距离度量大汇总(7-余弦距离(Cosine Distance))

余弦距离(Cosine Distance)衡量的是两个向量在方向上的差异性,而不是在大小上的差异。

悦学共鸣,温柔以待,汇聚光芒,共同成长 2579

POJ-2251 Dungeon Master (BFS+优先队列)

这题是今年4月我们校队选拔时的最后一题,当时用的是一样的方法怎么做却都是WA,最后也没做出来;时隔3个月再做一遍才AC,也算填上了一个坑。。。orz Description 你被困在一个三维的空间中,现在要寻找最短路径逃生! 空间由立方体单位构成 你每次向上下前后左右移动一个单位需要一分钟 你不能对角线移动并且四周封闭 是否存在逃出生天的可能性?如果存在,则需要多少时间? Input 输入第一行...

Irimsky 251

5.2.4_标志位的生成

计算机组成原理之标志位的生成

人生得意须尽欢 7584

AUTOSAR&UDS 理论要点及isolar实战-DEM模块

从这节开始,将讲解UDS诊断中非常重要的知识点:故障事件触发、故障信息上报、故障信息处理、故障信息存储和故障系统降级,后续会陆续更新。

cqaa11的博客 552

Poj 2251 Dungeon Master [简单搜索,BFS]

POJ 2251 Dungeon Master 题目链接: 题目描述: You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes one...

weixin_31808637的博客 169

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

Dungeon Master POJ - 2251 (三维空间BFS搜索)

题目链接:https://vjudge.net/problem/POJ-2251 题目描述:给定一个长宽高分别为R、C、L的立体空间,S代表起点,E表示终点,"."表示可通过,"#"表示不可通过,每次可从当前坐标向前后左右上下六个方向移动,但是不可以对角移动。求起点到终点最短路,若不可达,输出“Trapped!”。 思路;BFS常适用于搜索最短路径的解,BFS过程中搜索到的解一定是离根最近的,

smwqd_yehua_cx的博客 381

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

POJ2251 Dungeon Master —— BFS

题目链接:http://poj.org/problem?id=2251 Dungeon Master Time Limit:1000MS Memory Limit:65536K Total Submissions:37296 Accepted:14266 ...

alince20008的博客 206

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

POJ - 2251 Dungeon Master (三维地图内的 bfs 找最短距离)

POJ - 2251 Dungeon Master (三维地图内的 bfs 找最短距离) You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It...

weixin_43179892的博客 271

POJ2251—— BFS——Dungeon Master

http://poj.org/problem?id=2251 /* 简单bfs,向六个方向拓展 */ /************************************************ * Author :Powatr * Created Time :2015-8-9 9:23:15 * File Name :B.cpp ...

dgjm4087的博客 154

POJ 2251 Dungeon Master(BFS)

POJ 2251 Dungeon Master Description You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes on...

weixin_30567471的博客 108

POJ - 2251 - Dungeon Master(三维bfs)

Alibaba_lhl的博客 242

POJ2251 Dungeon Master BFS

Description You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes one minute to move one

colorfulshark 1081

Dungeon Master POJ - 2251 BFS

一、内容 题意:给定一个3D的图,你能走6个方向,问从起点到终点最少的步数。 二、思路 bfs搜素一下。 三、代码 #include <cstdio> #include <cstring> #include <queue> #include <iostream> using namespace std; int l, r, c, sl, sx,...

Tizzi的博客 873

POJ2251:Dungeon Master(BFS)

Description You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes one minute to move one unit

ACM!荣耀之路! 1万+

【 POJ 2251】 Dungeon Master 三维BFS

POJ 2251 Dungeon Master You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be fille...

天才小熊猫的博客 400

POJ 2251 Dungeon Master 【三维bfs】

题意 走迷宫,可以跳跃走到下一层,从S到E每走一步花费一分钟,问你如果能到终点E,需要多少分钟,或者直接说明不能到达终点E 思路 除了在平面x0y上下左右行走之外,还可在z轴的方向上行走,这样只需要把那个控制方向的数组开成三维的就可以了,这里注意一点的是,三维数组的第一个是z,其他的地方和二维的类似,就没什么难点了。 code #include<iostream> #include&l...

超逸の学习技术博客 678

[kuangbin带你飞]专题1-23 专题一 简单搜索 POJ 2251 Dungeon Master 宽度优先遍历BFS+三维数组的使用

[kuangbin带你飞]专题1-23 专题一 简单搜索 POJ 2251 Dungeon Master 宽度优先遍历BFS+三维数组的使用 总目录详见https://blog.youkuaiyun.com/mrcrack/article/details/107590709 在线测评地址https://vjudge.net/problem/POJ-2251 Status Accepted Time 16ms Memory 708kB Length 1195 Lang ..

mrcrack的博客 347

[bfs]poj2251 Dungeon Master

B - Dungeon Master Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u SubmitStatus Description You are trapped in a 3D dungeon and need to find the quickest way out! The d

童凌的技术博客 525
上一篇: HDU 2612 Find a way ——————BFS + 打表
下一篇: POJ 3278 Catch That Cow —————— BFS
陶鸿杰
博客等级 码龄9年 93粉丝 298原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值