- 浏览: 125243 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
leelege:
让一切GenericDao都去死吧
自己写的一个Hibernate CURD的封装 -
liuxuejin:
不用泛型的飘过,个人觉得没有什么必要,因为增删查的代码(简单的 ...
自己写的一个Hibernate CURD的封装 -
java113096:
finallygo 写道icanfly 写道ricoyu 写道 ...
自己写的一个Hibernate CURD的封装 -
jiluo093:
http://jiluo093.iteye.com/blog/ ...
自己写的一个Hibernate CURD的封装 -
piao_bo_yi:
Dev|il 写道yin_bp 写道Dev|il 写道dnst ...
自己写的一个Hibernate CURD的封装
Tempter of the Bone
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 26363 Accepted Submission(s): 7218
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
题意:意思是在地图中S代表起始点,每个点只能停留1秒,便会沉落,而D代表门的所在,将在t秒后打开然后关闭,问狗是否能安全逃出迷宫
//剪枝:当格子数小于t时候,不必搜索
AC代码:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 26363 Accepted Submission(s): 7218
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
题意:意思是在地图中S代表起始点,每个点只能停留1秒,便会沉落,而D代表门的所在,将在t秒后打开然后关闭,问狗是否能安全逃出迷宫
//剪枝:当格子数小于t时候,不必搜索
AC代码:
#include <iostream> #include <queue> using namespace std; char map[8][8]; int visit[8][8]; int n, m, t; int d[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}}; typedef struct{ int x, y, t; }Block; Block s_n, e_n; bool dfs(Block temp) { int i, cnt; // cout<<"x = "<<temp.x<<" y = "<<temp.y<<" t="<<temp.t<<endl; if(map[temp.x][temp.y] == 'D' && temp.t == t) return true; cnt = (t - temp.t) - abs(temp.x - e_n.x) - abs(temp.y - e_n.y); if(cnt < 0 || cnt & 1) return false; for(i = 0; i < 4; i++) { Block cur; cur.x = temp.x + d[i][0]; cur.y = temp.y + d[i][1]; cur.t = temp.t + 1; if(cur.t > t) continue; if(cur.x >= 0 && cur.x < n && cur.y >=0 && cur.y < m && (map[cur.x][cur.y] == '.' || map[cur.x][cur.y] == 'D') && !visit[cur.x][cur.y]) { visit[cur.x][cur.y] = 1; if(dfs(cur)) return true; visit[cur.x][cur.y] = 0; } } return false; } int main() { int i, j, wall; while(cin>>n>>m>>t) { wall = 0; if(!n && !m && !t) break; for(i = 0; i < n; i++) for(j = 0; j < m; j++) { cin>>map[i][j]; if(map[i][j] == 'S') { s_n.x = i; s_n.y = j; }else if(map[i][j] == 'D') { e_n.x = i; e_n.y = j; }else if(map[i][j] == 'X') { wall++; } } if(n * m - wall < t) { cout<<"NO"<<endl; continue; } s_n.t = 0; memset(visit, 0, sizeof(visit)); if(dfs(s_n)) cout<<"YES"<<endl; else cout<<"NO"<<endl; } return 0; }
发表评论
-
求n个元素集合的子集(幂集)或n个元素的组合
2011-10-21 13:19 3203回溯法是设计递归过程的一种重要方法,它的求解过程是遍历一个状态 ... -
螺旋矩阵
2011-10-19 13:26 1016给一个正整数n,输出一个n*n的螺旋矩阵 螺旋矩阵可以是逆时针 ... -
HDU2896(病毒侵袭)
2011-09-26 13:46 929病毒侵袭 Time Limit: 2000/1 ... -
HDU2060(Snooker)
2011-09-17 19:20 910Snooker Time Limit: 1000/1000 M ... -
HDU1166(敌兵布阵)
2011-09-17 12:55 857敌兵布阵 Time Limit: 2000/1000 MS ( ... -
HDU1754 I Hate It
2011-09-16 23:40 1061参考资料:http://www.cppblog.com/MiY ... -
HDU1686Oulipo
2011-09-14 22:15 884Oulipo Time Limit: 3000/1000 MS ... -
HDU2100Lovekey
2011-09-12 17:16 730Lovekey Time Limit: 3000/1000 M ... -
HDU3368 Reversi(黑白棋)
2011-09-11 23:04 1069Reversi Time Limit: 5000/2000 M ... -
求一个集合的全排列
2011-09-11 14:49 820#include <iostream> usin ... -
HDU1175连连看
2011-09-09 23:24 794连连看 Time Limit: 20000/10000 MS ... -
HDU1711Number Sequence
2011-09-09 13:09 743Number Sequence Time Limit: 100 ... -
HDU1097A hard puzzle
2011-09-06 22:46 860A hard puzzle Time Limit: 2000/ ... -
HDU1004Let the Balloon Rise
2011-09-06 09:44 537Let the Balloon Rise Time Limit ... -
HDU2061Treasure the new start, freshmen!
2011-08-24 14:06 1014Treasure the new start, freshme ... -
HDU2251Seinfeld
2011-08-24 13:39 898Seinfeld Time Limit: 2000/1000 ... -
HDU2083简易版之最短距离
2011-08-22 15:30 920简易版之最短距离 Time Limit: 1000/1000 ... -
HDU2093考试排名
2011-08-12 09:58 882考试排名 Time Limit: 1000/1 ... -
HDU2057A + B Again
2011-08-12 00:09 918A + B Again Time Limit: 1000/10 ... -
HDU2068RPG的错排
2011-08-10 22:45 755RPG的错排 Time Limit: 1000/1000 MS ...
相关推荐
* 题目1010:Tempter of the Bone,涉及到递归搜索的概念。 * 题目1016:Prime Ring Problem,涉及到递归搜索的概念。 * 题目1026:Ignatius and the Princess I,涉及到完全搜索的概念。 2. 图的遍历:深度优先...
例如,"HDU1010 Tempter of the Bone.cpp"可能就是利用DFS解决了一种寻找最短路径或解谜的问题。 另一方面,广度优先搜索(BFS)则是一种从根节点开始,逐层搜索直至找到目标的算法。BFS通常用于找出图中两个节点的...
这个压缩包文件包含的是从HDU题目ID1010到2500之间的部分解题报告,对于想要提升编程能力、学习算法知识的ACMer来说,是一份宝贵的资源。 这些解题报告通常会包含以下几个方面的重要知识点: 1. **题目描述**:每...
杭州电子科技大学oj平台上的第1010题,是关于搜索的题目,很不错的题
本报告围绕“ACM.rar”这个压缩包,我们将深入探讨其中涉及到的三道题目——HDU1010、ZOJ1010和ZOJ1015,并分享一些原创解题思路,尽管这些算法可能并非最优,但它们为我们提供了一种独特的视角来理解和解决问题。...
The least common multiple (LCM) of a set of positive integers is the smallest positive integer which is divisible by all the numbers in the set. For example, the LCM of 5, 7 and 15 is 105. Input Input...
HDU(杭州电子科技大学在线评测系统)是一个深受程序员喜爱的在线编程练习平台,它提供了丰富的算法题目供用户挑战,帮助他们提升编程技能和算法理解能力。"hdu.rar_hdu"这个压缩包文件很可能是某位程序员整理的他在...
搜索题是 ACM HDU 题目分类中的一大类,例如,1010 搜索题,剪枝很关键;1016 经典的搜索;1026 搜索;1043 经典搜索题,八数码问题;1044 稍微有点麻烦的搜索题;1045 搜索题,可用匹配做 等等。 贪心算法 贪心...
【标题】"HDU_2010.rar"是一个压缩包文件,其中包含了与"HDU 2010"相关的资源,特别是针对"HDU ACM20"比赛的编程题目。"hdu 2010"和"hdu 20"可能是该比赛的不同简称或分类,而"hdu acm20"可能指的是该赛事的第20届...
【标题】"HDU题目java实现"所涉及的知识点主要集中在使用Java编程语言解决杭州电子科技大学(HDU)在线评测系统中的算法问题。HDU是一个知名的在线编程竞赛平台,它提供了大量的算法题目供参赛者练习和提交解决方案...
The first line of the input contains an integer T(1≤T≤10), denoting the number of test cases. In each test case, there are two integers k,m(1≤k≤1018,1≤m≤100). Output For each test case, print ...
### hdu1250高精度加法 #### 背景介绍 在计算机科学与编程竞赛中,处理大整数运算(特别是加法、减法、乘法等)是常见的需求之一。当数字的位数超过了标准数据类型(如`int`、`long`等)所能表示的最大值时,就需要...
【标题】"HDU DP动态规划"涉及到的是在算法领域中的动态规划(Dynamic Programming,简称DP)技术,这是解决复杂问题的一种高效方法,尤其适用于有重叠子问题和最优子结构的问题。动态规划通常用于优化多阶段决策...
HDU1059的代码
hdu1001解题报告
hdu 1574 passed sorce
【标题】"hdu.rar_HDU 1089.cpp_OJ题求和_hdu_horsekw5_杭电obj" 提供的信息是关于一个压缩文件,其中包含了一个名为 "HDU 1089.cpp" 的源代码文件,这个文件是为了解决杭州电子科技大学(Hangzhou Dianzi ...
hdu2101AC代码
【ACM HDU】指的是在ACM(国际大学生程序设计竞赛,International Collegiate Programming Contest)中,参赛者在杭州电子科技大学(Hangzhou Dianzi University,简称HDU)的在线评测系统上完成并已解决的题目集合...
【标题】:杭电ACMhdu1163 【描述】:这是一道源自杭州电子科技大学(Hangzhou Dianzi University,简称HDU)的ACM编程竞赛题目,编号为1163。这类问题通常需要参赛者利用计算机编程解决数学、逻辑或算法上的挑战,...