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) 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…
Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 58766    Accepted Submission(s): 15983 Problem Description The doggie found a bone in an ancient maze, which fascinated him a…
题意:从S走到D,能不能恰好用T时间. 析:这个题时间是恰好,并不是少于T,所以用DFS来做,然后要剪枝,不然会TEL,我们这样剪枝,假设我们在(x,y),终点是(ex,ey), 那么从(x, y)到(ex, ey),要么时间正好是T-你已经走过的时间,要么要向别的地方先拐一下,以凑出这个正好时间,既然要拐一下,那么一定要回来, 所以时间肯定得是偶数,要不然完不成(回不来), 所以(t - abs(ex-x) - abs(ey-y) - cnt ),如果是奇数就剪枝.然而用C++交就TLE,用G…
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 despe…
Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 125945    Accepted Submission(s): 33969 Problem Description The doggie found a bone in an ancient maze, which fascinated him a…
Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 149833    Accepted Submission(s): 39945 Problem Description The doggie found a bone in an ancient maze, which fascinated him a…
点我看题目 题意 : 一个N×M的迷宫,D是门的位置,门会在第T秒开启,而开启时间小于1秒,问能否在T秒的时候到达门的位置,如果能输出YES,否则NO. 思路 :DFS一下就可以,不过要注意下一终止条件再判断一下时间,还有因为题目中要求走过的路要变成墙,所以每次走的时候要注意一下把路变成墙,但是如果你不走这条路了,要记得变回来.还有这个题必须剪枝,否则超时超到疯啊,DFS函数中那个剪枝不怎么好想,T-t代表的是在当前位置还需要T-t步路.而fabs(ex-x)+fabs(ey-y)指的是当前位置…
http://acm.hdu.edu.cn/showproblem.php?pid=1010 题意:就是给出了一个迷宫,小狗必须经过指定的步数到达出口,并且每个格子只能走一次. 首先先来介绍一下奇偶性剪枝: 在这道题目中,如果使用剪枝的话,可以节省不少的时间. 在这道题目中,每次dfs循环时都可以判断一下小狗当前位置与终点所相差的步数,如果不为偶数的话,说明到达不了终点,就可以退出这个循环,不必继续dfs了. 在这道题目中,由于每个格子只能经过一次,所以经过一次后,可以把该点位置改为'X',然后…
题目链接 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…
题意:有一副二维地图'S'为起点,'D'为终点,'.'是可以行走的,'X'是不能行走的.问能否只走T步从S走到D? 题解:最容易想到的就是DFS暴力搜索,,但是会超时...=_=... 所以,,要有其他方法适当的剪枝:假设当前所在的位置为(x,y),终点D的位置为(ex,ey); 那么找下规律可以发现: 当 |x-ex|+|y-ey| 为奇数时,那么不管从(x,y)以何种方式走到(ex,ey)都是花费奇数步:当为偶数时同理.  这即是所谓的奇偶性剪枝.这样剪枝就可以复杂度就变为原来暴力DFS的开…