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

【题意】

在这里输入题意

【题解】

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. C# Excel文件导入操作

    Excel文件导出的操作我们经经常使用到,可是讲一个Excel文档导入并显示到界面还是第一次用到. 以下简介下在C#下怎样进行Excel文件的导入操作. 首先加入两个引用 using System.I ...

  2. Log4j2 与 SpringMVC 整合

    log4j2不仅仅是log4j的简单升级,而是整个项目的重构.官网地址:http://logging.apache.org/log4j/2.x/,大家能够从官网的介绍看出它相比log4j第1代的种种长 ...

  3. 通过js动态创建button

    通过js动态创建button 一.实例描述 通过JS的DOM对象,实现元素的动态创建. 二.效果 三.代码 <!DOCTYPE html> <html lang="zh-c ...

  4. Ajax往后台传参数,无参数,一个参数,多个参数,一个对象等

    原文:http://www.cnblogs.com/chenwolong/p/Get.html //无参数请求-简单示例 $(document).ready(function () { $.ajax( ...

  5. Vectorized implementation

    Vectorization Vectorization refers to a powerful way to speed up your algorithms. Numerical computin ...

  6. jdbc的数据库驱动类DriverManager.getConnection()详解

    1.Oracle8/8i/9i数据库(thin模式) Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); ...

  7. POJ——T 2752 Seek the Name, Seek the Fame

    http://poj.org/problem?id=2752 Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 20418   ...

  8. opencv标定程序(改动)

    转载请注明来自:http://blog.csdn.net/zhouyelihua/article/details/38421377 资源下载见:点击打开链接 百度云盘免积分下载:https://pan ...

  9. UVa 11743 - Credit Check

    题目:推断卡号是否合法,给你4组4位的数字.偶数位的2倍的位和加上奇数位的和,推断尾数是否为0. 分析:简单题,模拟. 直接依照提议推断就可以. 说明:460题,加油! #include <io ...

  10. 点击事件-click,longclick

    今天在修改一个问题的时候,遇到了click,longclick事件触发情况.记录下来. 代码 tView.setOnLongClickListener(new OnLongClickListener( ...