HDU 1241 (DFS搜索+染色)】的更多相关文章

题目链接:  http://acm.hdu.edu.cn/showproblem.php?pid=1241 题目大意:求一张地图里的连通块.注意可以斜着连通. 解题思路: 八个方向dfs一遍,一边dfs一边染色,断了之后换新颜色. 做法类似Tarjan.orz,我是不是刷错顺序了. #include "cstdio" #include "cstring" #include "iostream" #include "string"…
Oil Deposits HDU - 1241 The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that divides the land into numerous squar…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1045 题目大意:在不是X的地方放O,所有O在没有隔板情况下不能对视(横行和数列),问最多可以放多少个O. 解题思路: 题目规模比较小(4*4),可以DFS解决. 对于一个点,要么放,要么不放. 放的话条件必须是上下左右四个方向扫到边界且不首先碰到X. 可以只对放的点进行标记,而对于不放的点不进行标记,这样当dep>n*n的时候及时return就行了. 注意每次dfs只需要按顺序考虑一个点,而不要同…
题目链接:  http://acm.hdu.edu.cn/showproblem.php?pid=1010 题目大意:给定起点和终点,问刚好在t步时能否到达终点. 解题思路: 4个剪枝. ①dep>t剪枝 ②搜到一个解后剪枝 ③当前走到终点最少步数>满足条件还需要走的步数剪枝(关键) ③奇偶剪枝(关键):当前走到终点步数的奇偶性应该与满足条件还需要走的步数奇偶性一致. 其中三四两步放在一步中写:remain=abs(x-ex)+abs(y-ey)-abs(dep-t) 奇偶剪枝的原理:abs(…
Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 107138    Accepted Submission(s): 29131 Problem Description The doggie found a bone in an ancient maze, which fascinated him a…
Oil Deposits Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 31745    Accepted Submission(s): 18440 Problem Description The GeoSurvComp geologic survey company is responsible for detecting under…
8个方向求联通块,经典问题. AC代码 #include<cstdio> #include<cstring> #include<algorithm> #include<queue> using namespace std; const int maxn = 100 + 5; const int dx[] = {0,0,-1,1,-1,-1,1,1}; const int dy[] = {1,-1,0,0,1,-1,1,-1}; int n, m; char…
Oil Deposits Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 38801    Accepted Submission(s): 22518 Problem Description The GeoSurvComp geologic survey company is responsible for detecting under…
HDU 1241  Oil Deposits L -DFS Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u   Description The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large r…
HDOJ(HDU).1241 Oil Deposits(DFS) [从零开始DFS(5)] 点我挑战题目 从零开始DFS HDOJ.1342 Lotto [从零开始DFS(0)] - DFS思想与框架/双重DFS HDOJ.1010 Tempter of the Bone [从零开始DFS(1)] -DFS四向搜索/奇偶剪枝 HDOJ(HDU).1015 Safecracker [从零开始DFS(2)] -DFS四向搜索变种 HDOJ(HDU).1016 Prime Ring Problem (…