POJ 2386 Lake Counting(dfs)
来源:互联网 发布:校园暴力看待 知乎 编辑:程序博客网 时间:2024/05/16 02:46
Lake Counting
题目链接:
http://poj.org/problem?id=2386
解题思路:
搜索大水题。。。
AC代码:
#include <iostream>#include <cstdio>using namespace std;int n,m;char a[110][110];void dfs(int x,int y){ if(x<0 || x>=n || y<0 || y>=m|| a[x][y] == '.') return; a[x][y] = '.'; dfs(x-1,y); dfs(x-1,y-1); dfs(x,y-1); dfs(x+1,y-1); dfs(x+1,y); dfs(x+1,y+1); dfs(x,y+1); dfs(x-1,y+1);}int main(){ while(~scanf("%d%d",&n,&m)){ int sum = 0; for(int i = 0; i < n; i++) scanf("%s",a[i]); for(int i = 0; i < n; i++) for(int j = 0; j < m; j++){ if(a[i][j] == 'W'){ sum++; dfs(i,j); } } printf("%d\n",sum); } 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
- CodeChef2015年8月问题
- node 纪录
- 推荐引擎算法学习导论:协同过滤、聚类、分类
- CharSequence与String的区别
- Linux开机自启动程序详解
- POJ 2386 Lake Counting(dfs)
- 使UDP服务器尽可能可靠
- Cocos2d-JS中使用Cocos Studio资源02:登录界面
- 【Java代码保护技术】代码混淆
- 26-网络编程-07-网络编程(UDP协议-发送端)
- HierarchyViewer源代码理解(一)
- 【Android进阶篇】Fragment的两种加载方式
- Hadoop之HDFS命令
- Leetcode -- Longest Common Prefix