poj 2386 Lake Counting(dfs)
来源:互联网 发布:网页游戏自动挂机软件 编辑:程序博客网 时间:2024/05/23 21:16
基础dfs
#include <cstdio>int n,m;char Map[110][110];int next[8][2] = {{0,1},{1,0},{1,1},{-1,-1},{0,-1},{-1,0},{1,-1},{-1,1}};void DFS(int x, int y){ int tx,ty; for(int k = 0; k < 8; ++k) { tx = x + next[k][0]; ty = y + next[k][1]; if(tx < 0 || ty < 0 || tx >= n || ty >= m) continue; if(Map[tx][ty] == 'W') { Map[tx][ty] = '.'; DFS(tx,ty); } } return;}int main(){ while(scanf("%d %d",&n,&m) != EOF) { for(int i = 0; i < n; ++i) for(int j = 0; j < m; ++j) scanf(" %c",&Map[i][j]); int res = 0; for(int i = 0; i < n; ++i) for(int j = 0; j < m; ++j) { if(Map[i][j] == 'W') { Map[i][j] = '.'; DFS(i,j); ++res; } } printf("%d\n",res); } return 0;}
0 0
- poj 2386Lake Counting(DFS, BFS)
- Lake Counting (POJ No.2386) DFS
- POJ 2386 Lake Counting(DFS)
- POJ 2386 Lake Counting (DFS)
- poj 2386Lake Counting(dfs)
- POJ 2386 Lake Counting(DFS)
- POJ 2386 Lake Counting(dfs)
- POJ 2386 Lake Counting(dfs)
- POJ 2386 Lake Counting(简单dfs)
- POJ 2386 Lake Counting (DFS)
- poj 2386 Lake Counting(dfs)
- POJ 2386 Lake Counting(经典dfs)
- POJ-2386--Lake Counting---DFS(深搜)
- POJ 2386 Lake Counting (DFS)
- poj 2386 Lake Counting (DFS~)
- POJ 2386 Lake Counting (dfs)
- POJ Lake Counting 2386(DFS)
- DFS:Lake Counting POJ 2386
- 解决filter拦截request中body内容后,字符流关闭,无法传到controller的问题
- pandas的数据结构-DataFrame1
- iOS开发进阶 - 富文本正则替换表情
- HTTP POST请求报文格式分析与Java实现文件上传
- CentOS安装Nginx 报错“configure: error: the HTTP rewrite module requires the PCRE library”解决办法
- poj 2386 Lake Counting(dfs)
- 【JavaScript】 判断横竖屏
- C++开源日志库选择
- java 稀疏矩阵
- 解决LibclangError: [Error 193] %1 不是有效的 Win32. To provide e Config.set_library_path() or Config.
- 一:Spark介绍
- 搜索二维矩阵
- 头文件和宏模板
- mybatis一对多查询过程只查询了一个结果