题意: 必须在第t秒走到格子D上,S为起点,D为终点,点就是可以走,X就是墙. 思路: 将迷宫外围四面都筑墙‘X’.深度搜索+奇偶剪枝,再加一个剪枝“无法在指定时间内到达”. #include <iostream> #include <vector> #include <string> #include <math.h> using namespace std; vector<string> v; int n,m; int x_1,y_1,x_2…
传送门: HDU:http://acm.hdu.edu.cn/showproblem.php?pid=1010 ZOJ:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1110 题目大意: 一只狗陷入了迷宫,他每秒必须走一步,并且不能重复走已经走过的地方,给定一个出口,要求在恰好为T的时间到达,如果可以,输出YES否则NO 不断的TLE,然后搜了下题解. 这题最漂亮的剪枝就在于奇偶的判断上.Orz DFS过程中,设终点的坐标为…
HDU 1010 题目大意:给定你起点S,和终点D,X为墙不可走,问你是否能在 T 时刻恰好到达终点D. 参考: 奇偶剪枝 奇偶剪枝简单解释: 在一个只能往X.Y方向走的方格上,从起点到终点的最短步数为T1,并记其他任意走法所需步数为T2,则T2-T1一定为偶数. 即若某一点到终点的最短步数为T1,且T3-T1为奇数,则一定无法话费T3步恰好到达终点. /*HDU 1010 ------ Tempter of the Bone DFS*/ #include <cstdio> #include…
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…
  如果所给的时间(步数) t 小于最短步数path,那么一定走不到. 若满足t>path.但是如果能在恰好 t 步的时候,走到出口处.那么(t-path)必须是二的倍数. 关于第二种方案的解释: 这种方案学名为“奇偶剪枝”.我们已知了最短的步数就是直角三角形的两条直角边,实际上的路径却不一定非要沿着这两条边走的.仔细看看只要是移动方向一直是右.下,那么走到的时候总步数也一定是path的.然而由于墙的存在或许我们不可能一直右.下的走下去.为了避开墙,我们可能会向左走,向上走等等.但为了到达目的地…
Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 82702    Accepted Submission(s): 22531 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): 58766    Accepted Submission(s): 15983 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): 70032    Accepted Submission(s): 19286 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): 88774    Accepted Submission(s): 24159 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) 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…