【例题 6-12 UVA - 572 】Oil Deposits
【链接】 我是链接,点我呀:)
【题意】
在这里输入题意
【题解】
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的更多相关文章
- UVA 572 -- Oil Deposits(DFS求连通块+种子填充算法)
UVA 572 -- Oil Deposits(DFS求连通块) 图也有DFS和BFS遍历,由于DFS更好写,所以一般用DFS寻找连通块. 下述代码用一个二重循环来找到当前格子的相邻8个格子,也可用常 ...
- UVA 572 Oil Deposits油田(DFS求连通块)
UVA 572 DFS(floodfill) 用DFS求连通块 Time Limit:1000MS Memory Limit:65536KB 64bit IO Format: ...
- uva 572 oil deposits——yhx
Oil Deposits The GeoSurvComp geologic survey company is responsible for detecting underground oil d ...
- UVa 572 Oil Deposits(DFS)
Oil Deposits The GeoSurvComp geologic survey company is responsible for detecting underground oil ...
- UVA - 572 Oil Deposits(dfs)
题意:求连通块个数. 分析:dfs. #include<cstdio> #include<cstring> #include<cstdlib> #include&l ...
- Uva 572 Oil Deposits
思路:可以用DFS求解.遍历这个二维数组,没发现一次未被发现的‘@’,便将其作为起点进行搜索.最后的答案,是这个遍历过程中发现了几次为被发现的‘@’ import java.util.*; publi ...
- UVa 572 - Oil Deposits (简单dfs)
Description GeoSurvComp地质调查公司负责探測地下石油储藏. GeoSurvComp如今在一块矩形区域探測石油.并把这个大区域分成了非常多小块.他们通过专业设备.来分析每一个小块中 ...
- UVa 572 Oil Deposits (Floodfill && DFS)
题意 :输入一个m行n列的字符矩阵,统计字符“@”组成多少个八连块.如果两个字符“@”所在的格子相邻(横竖以及对角方向),就是说它们属于同一个八连块. 分析 :可以考虑种子填充深搜的方法.两重for循 ...
- ACM:油田(Oil Deposits,UVa 572)
/* Oil Deposits Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tot ...
- Oil Deposits UVA - 572
The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSu ...
随机推荐
- Vijos——T1626 爱在心中
https://vijos.org/p/1626 描述 “每个人都拥有一个梦,即使彼此不相同,能够与你分享,无论失败成功都会感动.爱因为在心中,平凡而不平庸,世界就像迷宫,却又让我们此刻相逢Our H ...
- cogs 1500. 误差曲线
1500. 误差曲线 ★★ 输入文件:errorcurves.in 输出文件:errorcurves.out 评测插件时间限制:1 s 内存限制:256 MB [题目描述] Josep ...
- 【Android界面实现】使用GestureOverlayView控件实现手势识别
在Android开发中,我们不光能够使用已有的实现方式.并且,我们还能够利用Android这个智能手机平台.实现一些比較有特色的功能. 本篇文章介绍使用GestureOverlayView这个控件.实 ...
- 64。node.js 中间件express-session使用详解
转自:http://jinjiakarl.com/2018/06/09/node-js-%E4%B8%AD%E9%97%B4%E4%BB%B6express-session%E4%BD%BF%E7%9 ...
- 转 EL表达式
EL表达式 一.EL表达式简介 EL 全名为Expression Language.EL主要作用: 1.获取数据 EL表达式主要用于替换JSP页面中的脚本表达式,以从各种类型的web域 中检索java ...
- AIX lsof 命令
1.查看某端口运行情况 如查看22端口运行情况 # lsof –i:22 # lsof –i:22 –r ----每隔15秒显示22端口的监听情况. 2.查看活动的连接 如:查看ip地址为19 ...
- usermod---修改用户账户信息
usermod可用来修改用户帐号的各项设定. 语法 usermod [-LU][-c <备注>][-d <登入目录>][-e <有效期限>][-f <缓冲天数 ...
- Android图片处理——压缩、剪裁、圆角、保存
点击查看原文 项目中用到的关于图片的处理 public class UtilPicture { public static final String IMAGE_UNSPECIFIED = " ...
- code -结合实例总结代码下拉流程
1.查看手机需要的版本 1)如果手机本来就可以正常工作,可以使用指令 zhangshuli@zhangshuli-MS-:~/Desktop/day_note/plan$ adb shell getr ...
- 升级你的Linux日志系统
650) this.width=650;" onclick='window.open("http://blog.51cto.com/viewpic.php?refimg=" ...