/*
利用宽搜将每块积水填满,添加一个计数器,记下填满几块积水即答案
*/
#include<iostream>
using namespace std;
char a[][];
int r[][] = {{-,-},{-,},{,-},{-,},{,-},{,},{,},{,}};
int n,m;
void dfs(int x,int y)
{
//cout << x << " " << y << endl;
if(x < || x >= n) return ;
if(y < || y >= m) return ;
if(a[x][y] != 'W') return ;
a[x][y] = '.';
for(int i=; i<; ++i)
dfs(x+r[i][],y+r[i][]);
}
int main()
{
while(cin >> n >> m)
{
int ans = ;
for(int i=; i<n; ++i)
cin >> a[i];
for(int i=; i<n; ++i)
for(int j=; j<m; ++j)
if(a[i][j] == 'W')
{
++ans;
dfs(i,j);
}
cout << ans << endl;
}
return ;
}

POJ2386----Lake Counting的更多相关文章

  1. Poj2386 Lake Counting (DFS)

    Lake Counting Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 49414   Accepted: 24273 D ...

  2. POJ2386 Lake Counting 【DFS】

    Lake Counting Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20782   Accepted: 10473 D ...

  3. poj2386 Lake Counting(简单DFS)

    转载请注明出处:viewmode=contents">http://blog.csdn.net/u012860063?viewmode=contents 题目链接:http://poj ...

  4. poj-2386 lake counting(搜索题)

    Time limit1000 ms Memory limit65536 kB Due to recent rains, water has pooled in various places in Fa ...

  5. 【POJ - 2386】Lake Counting (dfs+染色)

    -->Lake Counting 直接上中文了 Descriptions: 由于近日阴雨连天,约翰的农场中中积水汇聚成一个个不同的池塘,农场可以用 N x M (1 <= N <= ...

  6. POJ_2386 Lake Counting (dfs 错了一个负号找了一上午)

    来之不易的2017第一发ac http://poj.org/problem?id=2386 Lake Counting Time Limit: 1000MS   Memory Limit: 65536 ...

  7. POJ 2386 Lake Counting(深搜)

    Lake Counting Time Limit: 1000MS     Memory Limit: 65536K Total Submissions: 17917     Accepted: 906 ...

  8. POJ 2386 Lake Counting

    Lake Counting Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 28966   Accepted: 14505 D ...

  9. bzoj1751 [Usaco2005 qua]Lake Counting

    1751: [Usaco2005 qua]Lake Counting Time Limit: 5 Sec  Memory Limit: 64 MB Submit: 168  Solved: 130 [ ...

  10. BZOJ 3385: [Usaco2004 Nov]Lake Counting 数池塘

    题目 3385: [Usaco2004 Nov]Lake Counting 数池塘 Time Limit: 1 Sec  Memory Limit: 128 MB Description     农夫 ...

随机推荐

  1. 【python】mongo删除数据

    参考:https://stackoverflow.com/questions/23334743/setting-justone-limiter-for-pymongo-remove-throws-ty ...

  2. react 为组件添加样式

    width/height/fontSize:可以直接写数字: style={ width:200,height:200 } 其他带数字的可以:数字+'px' style={ lineHeight:20 ...

  3. CF1029E

    一个看起来就不对的贪心居然是正解... 但仔细思考一下,这种贪心倒的确找不到反例.. 贪心思想:每次找出离根节点最远的点,然后由根节点向这个点的父节点连边,一直连到所有点都能被覆盖即可,这样构造出的一 ...

  4. Java 创建一个窗口,使其启动时位于屏幕中间

    import java.awt.Toolkit; import javax.swing.JFrame; public class WindowInTheMiddle extends JFrame { ...

  5. 升级centos6.8内核

    1.查看默认版本:uname -r 2.更新nss 3.安装elrepo的yum源,升级内核需要使用elrepo的yum源,在安装yum源之前还需要我们导入elrepo的key rpm --impor ...

  6. 使用vue-cli 引入bootstrap.min.css文件报错

    可以在index.html 里面引入boostrap.min.css文件 将bootstrap.min.css文件放置于static/css/文件夹中 然后再index.html文件中引入便可 < ...

  7. web页在微信中访问增加遮罩层 右上角弹出在浏览器中打开

    https://blog.csdn.net/zgsdzczh/article/details/79744838 web页在微信中访问增加遮罩层 右上角弹出在浏览器中打开   <style typ ...

  8. 【bzoj3589】动态树 树链剖分+树链的并

    题解: 树链剖分是显然的 问题在于求树链的并 比较简单的方法是 用线段树打标记覆盖,查询标记区间大小 Qlog^2n 代码: #include <bits/stdc++.h> using ...

  9. mySql中SUBSTRING_INDEX函数用法

    SUBSTRING_INDEX(str,delim,count) 返回字符串 str 中在第 count 个出现的分隔符 delim 之前的子串.如果 count 是一个正数,返回从最后的(从左边开始 ...

  10. byte数据常量池问题

    [代码] public class BufferPoolDemo { public static void main(String[] args) { Integer i1=127; Integer ...