关键词不能为空

当前您在: 主页 > 英语 >

杭电深搜例题hdu1010

作者:高考题库网
来源:https://www.bjmy2z.cn/gaokao
2021-02-02 05:00
tags:

-

2021年2月2日发(作者:有待商榷)


Tempter of the Bone


Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)


Total Submission(s): 37935 Accepted Submission(s): 10248



/?pid=1010




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




Sample Input


4 4 5


S.X.


..X.


..XD


....


3 4 5


S.X.


..X.


...D


0 0 0




Sample Output


NO


YES





题意:给出


T


,问第


T


秒是否能从


S


去到


D


< p>
百度到大牛的代码(看


cpp


就行,俺就大体讲一 下)




#include


using namespace std;



char map[8][8];


int r, c, ttime, x2, y2;





//ttime


是所给时间


T



< p>
r


:行、


c


:列】



bool flag;



















//x2



y2


是 终点坐标



int x_move[4] = {0, 1, -1, 0};


int y_move[4] = {1, 0, 0, -1};



void dfs (int x, int y, int t)




//t


是走到当前坐标时的时刻



{






if (t > ttime)




//


超时











return


;




//


下面的


tmp


的意义:


【剩余时间


(ttim e


-


t)(


记为

< br>left)


】与【从当前坐标


走到终点所需时间


(


abs(x-x2)


+


abs(y-y2)


)(


记为


win)


】的差,如果


tmp


是奇数,说明


left



wi n


的奇偶性不同!也就是说在第


T


秒时 ,不可能从当前坐标走到终点!







int tmp = ttime - t - abs(x-x2) - abs(y-y2);






if (tmp < 0 || tmp & 1)



//


奇偶剪枝,非常重要,很抽象



Orz...










return






for (int i = 0; i < 4; i++)






{










int tx = x + x_move[i];










int ty = y + y_move[i];










if (tx < 0 || ty < 0 || tx >= r || ty >= c)














continue;

-


-


-


-


-


-


-


-



本文更新与2021-02-02 05:00,由作者提供,不代表本网站立场,转载请注明出处:https://www.bjmy2z.cn/gaokao/597327.html

杭电深搜例题hdu1010的相关文章

  • 余华爱情经典语录,余华爱情句子

    余华的经典语录——余华《第七天》40、我不怕死,一点都不怕,只怕再也不能看见你——余华《第七天》4可是我再也没遇到一个像福贵这样令我难忘的人了,对自己的经历如此清楚,

    语文
  • 心情低落的图片压抑,心情低落的图片发朋友圈

    心情压抑的图片(心太累没人理解的说说带图片)1、有时候很想找个人倾诉一下,却又不知从何说起,最终是什么也不说,只想快点睡过去,告诉自己,明天就好了。有时候,突然会觉得

    语文
  • 经典古训100句图片大全,古训名言警句

    古代经典励志名言100句译:好的药物味苦但对治病有利;忠言劝诫的话听起来不顺耳却对人的行为有利。3良言一句三冬暖,恶语伤人六月寒。喷泉的高度不会超过它的源头;一个人的事

    语文
  • 关于青春奋斗的名人名言鲁迅,关于青年奋斗的名言鲁迅

    鲁迅名言名句大全励志1、世上本没有路,走的人多了自然便成了路。下面是我整理的鲁迅先生的名言名句大全,希望对你有所帮助!当生存时,还是将遭践踏,将遭删刈,直至于死亡而

    语文
  • 三国群英单机版手游礼包码,三国群英手机单机版攻略

    三国群英传7五神兽洞有什么用那是多一个武将技能。青龙飞升召唤出东方的守护兽,神兽之一的青龙。玄武怒流召唤出北方的守护兽,神兽之一的玄武。白虎傲啸召唤出西方的守护兽,

    语文
  • 不收费的情感挽回专家电话,情感挽回免费咨询

    免费的情感挽回机构(揭秘情感挽回机构骗局)1、牛牛(化名)向上海市公安局金山分局报案,称自己为了挽回与女友的感情,被一家名为“实花教育咨询”的情感咨询机构诈骗4万余元。

    语文