/*
利用宽搜将每块积水填满,添加一个计数器,记下填满几块积水即答案
*/
#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. (不断更新)关于显著性检测的调研-Salient Object Detection: A Survey

    <Salient Object Detection: A Survey>作者:Ali Borji.Ming-Ming Cheng.Huaizu Jiang and Jia Li 基本按照文 ...

  2. 【ES】学习11-多桶排序

    聚合结果的排序 默认:桶会根据 doc_count 降序排列. 内置排序: 设置按doc_count升序排序:注意order,_count GET /cars/transactions/_search ...

  3. Python if __name__ == '__main__':(以主程序形式执行)

    在外部调用某个模块时,可能会将只能在本模块执行的代码给执行了,有没有什么办法让某些特定的代码指定只能在自身运行时才执行被调用时不执行呢?使用if __name__ == '__main__':. 示例 ...

  4. Jmeter BeanShell PostProcessor提取json数据

    需求:提取sample返回json数据中所有name字段值,返回的json格式如下: {“body”:{“apps”:[{“name”:”111”},{“name”:”222”}]}} jmeter中 ...

  5. selenium 操作复选框

    场景 从上一节的例子中可以看出,webdriver可以很方便的使用findElement方法来定位某个特定的对象,不过有时候我们却需要定位一组对象, 这时候就需要使用findElements方法. 定 ...

  6. C++ Primer 笔记——顺序容器

    1.标准库中定义了一些顺序容器,所有顺序容器都提供了快速顺序访问元素的能力. 2.如果容器的元素类型没有默认构造函数,那么在构造这个容器的时候不能只指定这个容器的数目,因为没有办法默认构造这些元素. ...

  7. 调试WebApi的一些方法

    1.Get方法时,直接用浏览器访问 2.Postman 3.用HttpClient调用 privatevoid GetData() { using (HttpClient client = new H ...

  8. C/C++字节序(大端/小端)判断

    C/C++大端小端判断 说的是变量的高字节.低字节在内存地址中的排放顺序. 变量的高字节放到内存的低地址中(变量的低字节放到内存的高地址中)==>大端 变量的高字节放到内存的高地址中(变量的低字 ...

  9. One point compactification

    Theorem (One point compactification) Any locally compact space \(X\) can be embedded in another comp ...

  10. 【AtCoder】ARC071

    ARC071 C - 怪文書 / Dubious Document 题目大意:给n个字符串,每个字符串可以通过扔掉一些字母将剩下的字母重排得到新的字符串,求n个字符串都能拼出的字符串且长度最大,若有多 ...