UVA572 Oil Deposits(DFS求连通块(floodfill 种子填充))
来源:互联网 发布:php分布式架构 编辑:程序博客网 时间:2024/06/10 09:15
注释后补
#include<cstdio>#include<cstring>const int maxn = 100 + 5;char pic[maxn][maxn];int m, n, idx[maxn][maxn];void dfs(int r, int c, int id) { if(r < 0 || r >= m || c < 0 || c >= n) return ; if(idx[r][c] > 0 || pic[r][c] != '@') return ; idx[r][c] = id; for(int dr = -1; dr <= 1; dr ++) for(int dc = -1; dc <= 1; dc ++) if(dr != 0 || dc != 0) dfs(r+dr, c+dc, id);}int main(){ while( scanf("%d%d", &m, &n) == 2 && m && n) { for(int i = 0; i < m; i++) scanf("%s", pic[i]); memset(idx, 0, sizeof(idx)); int cnt = 0; for(int i = 0; i < m; i++) for(int j = 0; j < n; j++) if(idx[i][j] == 0 && pic[i][j] == '@') dfs(i, j, ++cnt); printf("%d\n", cnt); } return 0;}
0 0
- UVA572 Oil Deposits(DFS求连通块(floodfill 种子填充))
- UVA572 POJ1562 oil deposits(DFS求连通块问题)
- Uva572 Oil Deposits 【dfs求连通块】【例题6-12】
- 例题6-12 UVA572 Oil Deposits 基础dfs求连通块
- DFS:POJ1562-Oil Deposits(求连通块个数)
- Uva 572 Oil Deposits 油田 (DFS求连通块)
- UVa572 Oil Deposits(DFS)
- UVA572 Oil Deposits dfs
- UVa 572 Oil Deposits(DFS求8连通块)
- UVA 572 Oil Deposits dfs求连通块
- UVa - 572 - Oil Deposits(dfs求连通块)
- HDU 1241 Oil Deposits DFS求连通块
- HDU1241 Oil Deposits —— DFS求连通块
- Uva572种子填充<dfs>
- UVA572(Oil Deposits)(DFS)
- uva572 Oil Deposits(启发DFS)
- 经典第六章 例题 6-12 UVA 572 Oil Deposits(用DFS求连通块)
- 用DFS求连通块(油田Oil Deposits,UVa 572)
- The "Double-Checked Locking is Broken" Declaration
- 并行传输与串行传输(同步通信与异步通信区别)
- hive使用案例
- 在linux命令行下如何快速进入图形化界面
- SCCD 第6.5章 在文本框旁边添加按钮
- UVA572 Oil Deposits(DFS求连通块(floodfill 种子填充))
- android内存管理
- 关于STM32的FLASH操作【摘】
- 远程连接mysql 授权方法详解
- 欢迎使用CSDN-markdown编辑器
- C#解析XML详解(XPath以及带命名空间NameSpace)
- win32窗口创建 之 CreateDialog和DialogBox
- 重新系统学习Java收获的小tips
- 武汉大学无线传感实验床项目招标公告(开标时间2015年1月15日)