题目大意:输入一个二维网格,每个网格单元中只有两种字符'*'和'@','@'表示油田,'*'表示土地。求出网格中共有多少块油田?注意:所有横向,竖向,对角线方向连同的
油田算一块油田。
算法思想:
广度优先搜索,扫描每一个网格,判断该网格是否是油田且未被标记,若是则计数加1并且进行广搜标记所有与其相连通的油田,若不是则只标记。扫描完所有的网...
分类:
其他好文 时间:
2014-10-11 14:29:25
阅读次数:
181
题意 求n*m矩阵中'@'连通块的个数 两个‘@’在一个九宫格内就属于一个连通块
最基础的DFS 遇到@就递归扫描周围8个并标记当前格子已访问 然后就得到答案了
#include
using namespace std;
const int N = 110;
char mat[N][N];
int dfs(int r, int c)
{
if(mat[r][c] != '@'...
分类:
其他好文 时间:
2014-10-10 19:06:14
阅读次数:
142
简单的DFS
Oil Deposits
Time Limit: 1000MS
Memory Limit: 10000K
Total Submissions: 12801
Accepted: 6998
Description
The GeoSurvComp geologic survey company is resp...
分类:
其他好文 时间:
2014-10-01 12:53:11
阅读次数:
152
Oil Deposits
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 12461 Accepted Submission(s): 7245
Problem Description
The GeoSurvComp ...
分类:
其他好文 时间:
2014-09-23 21:21:15
阅读次数:
155
Oil Deposits
Time Limit: 1000MS
Memory Limit: 10000K
Total Submissions: 12621
Accepted: 6888
Description
The GeoSurvComp geologic survey company is responsible for de...
分类:
其他好文 时间:
2014-08-18 18:39:22
阅读次数:
199
http://poj.org/problem?id=1562 Oil DepositsTime Limit:1000MSMemory Limit:10000KTotal Submissions:12595Accepted:6868DescriptionThe GeoSurvComp geologic...
分类:
其他好文 时间:
2014-08-16 20:54:51
阅读次数:
199
Oil Deposits
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d
& %I64u
Description
The GeoSurvComp geologic survey company is responsible for detecting underground oil ...
分类:
其他好文 时间:
2014-08-15 12:59:08
阅读次数:
208
Oil DepositsThe GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangula...
分类:
其他好文 时间:
2014-08-15 12:25:18
阅读次数:
306
1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 char map[105][105]; 7 8 int dir[8][2]={0, 1, 1, 0, -1, 0, 0, -1, 1, 1, 1, -1, -.....
分类:
其他好文 时间:
2014-08-14 01:14:27
阅读次数:
266
很简单很经典的DFS题目题意:'@'代表一块油田,在以它为中心的九宫格里的'@',也算同在一块油田,问所给矩阵中有多少块油田思路:遍历地图中的每一个格子,如果遇到'@',则DFS,将这块变为'*',然后八个方向继续DFS这样整个搜索完毕以后,这个map就全部变为'*'了第一次居然忘了做数组越界检测,...
分类:
其他好文 时间:
2014-08-05 07:20:38
阅读次数:
180