hdu 1010 Tempter of the Bone(DFS+剪枝优化)

MATLAB配置MinGW编译器的完整指南 本文提供了在Windows系统上为MATLAB配置MinGW编译器的完整指南。详细介绍了通过MATLAB附加功能管理器在线安装和手动离线安装两种核心方法,并重点说明了如何解决常见的“未找到支持的编译器”等错误。指南包含从版本检查、环境变量配置到最终使用mex命令验证的每一步,帮助用户顺利完成MATLAB与MinGW的集成,以支持C/C++代码编译。 阅读详情

Tempter of the Bone

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 38029    Accepted Submission(s): 10265


Problem Description
The doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze began to shake, and the doggie could feel the ground sinking. He realized that the bone was a trap, and he tried desperately to get out of this maze.

The maze was a rectangle with sizes N by M. There was a door in the maze. At the beginning, the door was closed and it would open at the T-th second for a short period of time (less than 1 second). Therefore the doggie had to arrive at the door on exactly the T-th second. In every second, he could move one block to one of the upper, lower, left and right neighboring blocks. Once he entered a block, the ground of this block would start to sink and disappear in the next second. He could not stay at one block for more than one second, nor could he move into a visited block. Can the poor doggie survive? Please help him.

Input
The input consists of multiple test cases. The first line of each test case contains three integers N, M, and T (1 < N, M < 7; 0 < T < 50), which denote the sizes of the maze and the time at which the door will open, respectively. The next N lines give the maze layout, with each line containing M characters. A character is one of the following:

'X': a block of wall, which the doggie cannot enter;
'S': the start point of the doggie;
'D': the Door; or
'.': an empty block.

The input is terminated with three 0's. This test case is not to be processed.

Output
For each test case, print in one line "YES" if the doggie can survive, or "NO" otherwise.

Sample Input
  
4 4 5 S.X. ..X. ..XD .... 3 4 5 S.X. ..X. ...D 0 0 0

Sample Output
  
NO YES

Author
ZHANG, Zheng

Source

Recommend
JGShining
 
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int tx[]={0,0,1,-1};
const int ty[]={1,-1,0,0};
char map[10][10];
int n,m,t,ans;
int dx,dy;
void dfs(int x,int y,int t)
{
   int z=abs(x-dx)+abs(y-dy);
    if(z>t)return;
    if(ans)return;
  for(int i=0;i<4;i++)
  {
    int nx=x+tx[i];
    int ny=y+ty[i];

    if(nx>=0&&nx<n&&ny>=0&&ny<m&&map[nx][ny]!='X'&&t)
    {
      if(map[nx][ny]=='.')
      {
        map[nx][ny]='X';
        t--;dfs(nx,ny,t);t++;map[nx][ny]='.';
      }
      if(map[nx][ny]=='D'&&t==1){ans=1;return;}
    }
  }
  return;
}
int main()
{
  int i,j,nx,ny;
  //freopen("3.txt","r",stdin);
  while(scanf("%d%d%d",&n,&m,&t)&&(n||m||t))
  { ans=0;
    for(i=0;i<n;i++)
    scanf("%s",map[i]);
    for(i=0;i<n;i++)
    for(j=0;j<m;j++)
    {
      if(map[i][j]=='S')
      {nx=i;ny=j;}
      if(map[i][j]=='D')
      {dx=i;dy=j;}
    }
    if(abs(nx-dx)+abs(ny-dy)>t||(nx+ny+dx+dy+t)&1)
    {
      printf("NO\n");continue;
    }dfs(nx,ny,t);
    if(ans)
    printf("YES\n");
    else
    printf("NO\n");
  }
  return 0;
}

带洞多边形如何分成凸多边形集合,对多边形进行凸分解? 摘要: 凸分解是计算几何中的经典问题,分为三角化和凸分解两种方法。三角化将带洞多边形转换为简单多边形并分割为三角形,常用算法包括耳剪法、单调多边形三角化等。凸分解则生成更少但更大的凸多边形,常用Hertel-Mehlhorn算法或基于凹点的递归切割。实际应用中建议使用CGAL、Poly2Tri等成熟库处理。三角化适合图形渲染,凸分解更适用于物理引擎和路径规划。关键步骤包括数据校验、选择合适的算法及后处理优化。 阅读详情

相关推荐

无迹卡尔曼滤波(UKF)推导

提出,使用了一种不同的方法来计算误差协方差矩阵。它不使用(连续时间)黎卡提方程(Riccati Equations,形如。的一类非线性方程)或(离散时间)协方差传播和更新规律。关键的思想是基于一组特殊的样本点来估计误差协方差,这些点被称为。无迹卡尔曼滤波(Unscented Kalman Filter),最初由。点(Sigma Points),这些点直接通过原始非线性模型传播。无迹变换表示有三个特殊样本点的高斯分布,称为。

生活如此美好,致敬每一个热爱“热爱”的人! 1788

Tempter of the Bone(DFS)

HDU1010 Tempter of the Bone 没有剪枝,超时 #include &lt;iostream&gt; #include&lt;cstdio&gt; #include&lt;string.h&gt; using namespace std; char map[10][10]; int flag,step; int d[4][2]={0,1,1,0,0,-1,-1,0}; ...

薄荷糖 147

服务器被矿工入侵记录

一次服务器被矿工入驻的处理记录

王瑞的技术专栏 1346

HDU-1010Tempter of the Bone(dfs+奇偶剪枝)

Tempter of the Bone 题目链接 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 157407 Accepted Submission(s): 41882 Problem Description The doggie...

孤风的博客 587

opencode 完全指南:终端AI编程助手的安装、模型配置与实战

在AI编程助手快速迭代的当下,开发者对终端环境下的自动化编码需求愈发强烈。以自然语言驱动代码修改、命令执行与测试验证,已成为提升工程效率的重要方向。这类工具普遍遵循模型无关的设计原则,通过兼容OpenAI格式的接口接入多种大模型,并借助多会话管理、Skills、Memory等机制实现可审查、可干预的闭环流程。从安装配置到日常使用,再到apihub网关与免费模型的接入,终端AI助手在代码审查、跨文件重构、浏览器自动化验证等场景中展现出独特价值。本文聚焦opencode这一开源CLI工具,详细拆解其核心定位、模

weixin_33868027的博客 426

AD20/Altium designer——如何进行DRC检查、冲突的错误如何改正

对于一个画完的PCB,我们常常需要进行DRC检查,确保板子的电器连接及制作工艺在设定规则的范围内,本篇将介绍如何对PCB进行后期DRC检查处理,确保电路板出现不必要错误。 1.DRC检查入口 2.DRC设置 3.错误分析 对于错误的内容,依据个人实际情况不同,其出现的原因都是因为与设计规则中的设定标准冲突,这里按遇到的错误进行修改讲解,其他错误同理。 4.常见错误分析及解决方法 (1) 解决方法:将未连接网络连接(...

嵌入式创客工坊的博客 5万+

搜索--HDU简单DFS

HDU 1241 Oil Deposit 水题一到。。。。。 #include #include #include #include #include using namespace std; int m,n; char ch[110][110]; int a[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}

Dragon 417

YOLOv26与其他目标检测算法的对比分析

本文对YOLOv26与其他主流目标检测算法进行了全面对比分析。YOLOv26在COCO数据集上达到96.0% mAP@0.5和79.0% mAP@0.5:0.95,显著优于其他YOLO系列算法,同时保持85FPS的推理速度和35MB的轻量级模型。相比两阶段算法(如Faster R-CNN),YOLOv26在速度、模型大小和内存占用方面优势明显;相比Anchor-free算法(如CenterNet),YOLOv26在速度和模型压缩方面更优。其核心创新包括动态锚框分配、自注意力机制和轻量级设计,使其成为适用于复

一键难忘的博客 1011

DFS+奇偶剪枝

hdu1010 Tempter of the Bone Problem Description The doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze began to shake, and the doggie could

老街# 240

控制科学与工程(自动化)保研经验【1】——预备篇

个人情况 学校:中末流211 专业:自动化(学科评估B-) 年份:2019 排名:4/128 绩点:4.16/5 竞赛:三个国二(包括数模国赛美赛)、两个省一(机器人、电子设计竞赛) 【本科期间竞赛做的比较多,是我的一大亮点,可以在筛简历这关适当弥补专业排名的不足】 科研:一个校级的大创项目(水) 夏令营报名:中科大科学岛、中科大本部、自动化所、沈自所、北航(仪器17系)、山大、浙江大学、南开、同...

Control Everything 1万+

面向可扩展的 ABAP CDS:EXTEND VIEW 全面实战与工程化指引

摘要: 本文深入讲解ABAP CDS的EXTEND VIEW功能,帮助开发者在标准或自建模型上安全扩展字段与关联。核心内容包括: 作用:避免直接修改标准CDS,通过轻量扩展添加业务字段和关联,降低维护风险。 语法要点:需定义CDS扩展实体名和Dictionary Append View名,支持添加普通字段、关联,但不允许聚合或修改原有结构。 限制:不能扩展含聚合、UNION的视图,且扩展字段需避免命名冲突。 工程实践:建议使用客户命名空间,区分结构扩展与元数据扩展,并注意功能性变更需通过其他方式实现。 示例

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

HDU 1010 Tempter of the Bone DFS(奇偶剪枝优化)

需要剪枝否则会超时,然后就是基本的深搜了 #include<cstdio> #include<stdio.h> #include<cstdlib> #include<cmath> #include<iostream> #include<algorithm> #include<cstring> ...

weixin_30536513的博客 75

机器人中的数值优化(十二)——带约束优化问题简介、LP线性规划

本系列文章主要是我在学习《数值优化》过程中的一些笔记和相关思考,主要的学习资料是深蓝学院的课程《机器人中的数值优化》和高立编著的《数值最优化方法》等,本系列文章篇数较多,不定期更新,上半部分介绍无约束优化,下半部分介绍带约束的优化,中间会穿插一些路径规划方面的应用实例

慕羽★的博客 3858

HDU 1010 Tempter of the Bone (DFS+奇偶剪枝)

奇偶剪枝得到新技能

n-1 744

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

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

vb 6.0并口开发操作实例

vb6并口开发,简体中文,试例内有inpout32.dll动态链接库

HDU 1010 DFS+剪枝

题目传送门 HDU 1010 Tempter of the Bone 套路很好理解,就是DFS。但是这次不需要使用vis数组因为不是寻找最短路,可以稍微绕一点远。 第一次TLE之后百度了一下题解,发现需要剪枝。剪枝的思路也很好理解,求当前节点到终点的曼哈顿距离,如果剩余的时间多于这个距离则继续前进,少于这个距离的return终止递归。另外这篇题解里面还提到了“奇偶剪枝”的这种想法(HDU

Kiritow的学园 513

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

【HDU】1010Tempter of the Bone【dfs+剪枝】

单纯用dfs会超时 要用剪枝优化 提供一组变态数据 6 6 37 S..... ...... ...... ...... ...... D..... NO #include&lt;bits/stdc++.h&gt; #include&lt;cstring&gt; using namespace std; struct node{ int x,y; }; int N,M,T; c...

以梦为马,诗酒趁年华的博客 140

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

【HDOJ】1010 Tempter of the Bone_天涯浪子_新浪博客

【题目】http://acm.hdu.edu.cn/showproblem.php?pid=1010 【报告】 一看这题目,哇,好简单啊,暴力DFS。然后TLE了…… 然后百度了一下,别人都用了个什么叫奇偶性剪枝的东西,我不是很懂,大概抄了一下,然后就AC了。 关于奇偶性剪枝的东西,有两个网站:http://www.cppblog.com/Geek/archive/...

为美好世界献上珂学 121

【HDU 1010】Tempter of the Bone(DFS,奇偶剪枝)

题意 狗狗要在特定时刻逃出N*M迷宫,迷宫已输入,‘.’表示可以走的路,’#’表示不能走的墙,’S’表示开始位置,‘D’表示结束位置。不能走回头路。 思路以及细节点 输入时将起点、终点位置记录,并将墙的vis置为true(不能 再 走了) DFS,先贴代码

Chen_yuazzy的博客 1766

HDU 1010 Tempter of the Bone(DFS,奇偶剪枝)

Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 101688    Accepted Submission(s): 27539 Problem Description The

AC_Dreameng 5433

hdu-1010 Tempter of the Bone(DFS+奇偶剪枝)

hdu-1010 Tempter of the Bone(DFS+奇偶剪枝)题目描述 Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 109915 Accepted Subm

oYinGui1 865

hdu 1010 Tempter of the Bone[dfs]

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1010

835

HDU OJ 1010 Tempter of the Bone【深搜】

原题连接:http://acm.hdu.edu.cn/showproblem.php?pid=1010 思路:dfs 深度优先搜索+剪枝 ; 1:因为是某个时刻正好到达door,所以要搜出所有的能到达door的情况,比较时间是否相等,故用深搜!! 2:只有一般的深搜搜索提交会超时,所以需要剪枝。。 剪枝如下: 1.如果当前搜索的深度(时间)大于时间t,中止搜索。 2.如果已

nyist_飘谊 2484

dfs与奇偶剪枝 Tempter of the bone——hdu1010

dfs与奇偶剪枝 Tempter of the bone——hdu1010

2301_80093604的博客 1081

【hdoj_1010】Tempter of the Bone(迷宫+剪枝)

题目:http://acm.hdu.edu.cn/showproblem.php?pid=1010 题目大意:给出一个迷宫(含起点和终点),要求找出一条路径,这条路径的长度必须为某个规定的长度. 在做本题之前,先学习了一下迷宫问题:http://blog.csdn.net/ten_sory/article/details/66975811 在理解迷宫问题的基础上,再做本题.本

tensory的博客 1166

HDU 1010 Tempter of the Bone(DFS+剪枝)

http://acm.hdu.edu.cn/showproblem.php?pid=1010 大神题解报告http://acm.hdu.edu.cn/forum/read.php?tid=6158 关于剪枝,没有剪枝的搜索不太可能,这题老刘上课的时候讲过两个剪枝,一个是奇偶剪枝,一个是路径剪枝 奇偶剪枝: 把矩阵标记成如下形式: 0,1,0,1,0 1,0,1...

aocang4831的博客 131

HDU 1010 Tempter of the Bone(DFS+剪枝)

题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1010 这题T

scf0920 1045
上一篇: hdu 4325 Flowers(线段树+哈希散列)
下一篇: USCAO section Mother's Milk(搜索)
剑不飞
博客等级 码龄15年 86粉丝 505原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址