【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

dfs..

【代码】

#include <bits/stdc++.h>
using namespace std; const int N = 100;
const int dx[8] = {-1,-1,-1,0,0,1,1,1};
const int dy[8] = {-1,0,1,-1,1,-1,0,1}; int n,m;
string s[N+10];
bool bo[N+10][N+10]; void dfs(int x,int y){
if (x <0 || x >=n || y<0 || y>=m || s[x][y]=='*') return;
if (bo[x][y]) return;
bo[x][y] = true;
for (int i = 0;i < 8;i++)
dfs(x+dx[i],y+dy[i]);
} int main(){
// freopen("rush.txt","r",stdin);
while(~scanf("%d%d",&n,&m) && n){
memset(bo,0,sizeof bo);
for (int i = 0;i < n;i++) cin >> s[i];
int cnt = 0;
for (int i = 0;i < n;i++)
for (int j = 0;j < m;j++)
if (!bo[i][j] && s[i][j]!='*'){
dfs(i,j);
cnt++;
}
printf("%d\n",cnt);
}
return 0;
}

【例题 6-12 UVA - 572 】Oil Deposits的更多相关文章

  1. UVA 572 -- Oil Deposits(DFS求连通块+种子填充算法)

    UVA 572 -- Oil Deposits(DFS求连通块) 图也有DFS和BFS遍历,由于DFS更好写,所以一般用DFS寻找连通块. 下述代码用一个二重循环来找到当前格子的相邻8个格子,也可用常 ...

  2. UVA 572 Oil Deposits油田(DFS求连通块)

    UVA 572     DFS(floodfill)  用DFS求连通块 Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format: ...

  3. uva 572 oil deposits——yhx

    Oil Deposits  The GeoSurvComp geologic survey company is responsible for detecting underground oil d ...

  4. UVa 572 Oil Deposits(DFS)

     Oil Deposits  The GeoSurvComp geologic survey company is responsible for detecting underground oil ...

  5. UVA - 572 Oil Deposits(dfs)

    题意:求连通块个数. 分析:dfs. #include<cstdio> #include<cstring> #include<cstdlib> #include&l ...

  6. Uva 572 Oil Deposits

    思路:可以用DFS求解.遍历这个二维数组,没发现一次未被发现的‘@’,便将其作为起点进行搜索.最后的答案,是这个遍历过程中发现了几次为被发现的‘@’ import java.util.*; publi ...

  7. UVa 572 - Oil Deposits (简单dfs)

    Description GeoSurvComp地质调查公司负责探測地下石油储藏. GeoSurvComp如今在一块矩形区域探測石油.并把这个大区域分成了非常多小块.他们通过专业设备.来分析每一个小块中 ...

  8. UVa 572 Oil Deposits (Floodfill && DFS)

    题意 :输入一个m行n列的字符矩阵,统计字符“@”组成多少个八连块.如果两个字符“@”所在的格子相邻(横竖以及对角方向),就是说它们属于同一个八连块. 分析 :可以考虑种子填充深搜的方法.两重for循 ...

  9. ACM:油田(Oil Deposits,UVa 572)

    /* Oil Deposits Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tot ...

  10. Oil Deposits UVA - 572

    The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSu ...

随机推荐

  1. 11.2.0.1升级到11.2.0.4报错之中的一个:UtilSession failed: Patch 9413827

    UtilSession failed: Patch 9413827 requires component(s) that are not installed in OracleHome. These ...

  2. php数组合并有哪三种方法

    php数组合并有哪三种方法 一.总结 一句话总结:array_merge():array_merge_recursive():‘+'号 $a = array('color'=>'red',5,6 ...

  3. Linux获取进程中变量

    列出所有进程 #include <linux/kernel.h> #include <linux/module.h> #include <linux/init.h> ...

  4. Kinect 开发 —— 进阶指引 (下)

    运动识别 利用运动识别(motion detection)来进行近景识别是最有意思的一种方式.实现运动识别的基本原理是设置一个起始的基准RGB图像,然后将从摄像头获取的每一帧影像和这个基准图像进行比较 ...

  5. UVALive 5292 Critical Links

    Critical Links Time Limit: 3000ms Memory Limit: 131072KB This problem will be judged on UVALive. Ori ...

  6. bitset也挺好用的

    http://www.cplusplus.com/reference/bitset/bitset/bitset/ std::bitset<16> foo; std::bitset<4 ...

  7. [React] Define defaultProps and PropTypes as static methods in class component

    class Toggle extends Component { static propTypes = { defaultOn: PropTypes.bool, on: PropTypes.bool, ...

  8. 运行 CMD 时,參数加引號常见问题

    在调用 CMD 时.如脚本中用 WScript.Shell 调用. 假设參数中有包括空格的长路径名时,必需要加引號才干正确被识别. 是的,大家都知道要加引號.但怎么加却easy被误解.这个问题,不时地 ...

  9. c# 查询sql 返回多个參数

    1.依据须要查询mysql 语句,返回三个须要的參数,不是数据集 2.编写函数例如以下: public static void GetParas(string 条件1, out string 返回值1 ...

  10. ubuntu16 升级后找不到 eth0 网卡 的解决方法

    ubuntu16 升级后找不到 eth0 网卡 的解决方法 今天在VPS上一时手痒,执行了升级命令 apt-get update 更新软件包索引,源 apt-get upgrade 更新软件包 apt ...