http://poj.org/problem?id=2386

这个题目与那个POJ 1562几乎是差不多的,只不过那个比这个输入要复杂一些

 #include <stdio.h>
#include <string.h>
#include <iostream> using namespace std; char str[][];
int dps(int i,int j)
{
if(str[i-][j-]=='W')
{
str[i-][j-]='#';
dps(i-,j-);
}
if(str[i-][j]=='W')
{
str[i-][j]='#';
dps(i-,j);
}
if(str[i-][j+]=='W')
{
str[i-][j+]='#';
dps(i-,j+);
}
if(str[i][j-]=='W')
{
str[i][j-]='#';
dps(i,j-);
}
if(str[i][j+]=='W')
{
str[i][j+]='#';
dps(i,j+);
}
if(str[i+][j-]=='W')
{
str[i+][j-]='#';
dps(i+,j-);
}
if(str[i+][j]=='W')
{
str[i+][j]='#';
dps(i+,j);
}
if(str[i+][j+]=='W')
{
str[i+][j+]='#';
dps(i+,j+);
} }
int main()
{
memset(str,,sizeof(str));
int m,n,i,j,ans;
scanf("%d%d",&m,&n);
for(i=;i<=m;i++)
scanf("%s",str[i]);
for(i=,ans=;i<=m;i++)
for(j=;j<n;j++)
{
if(str[i][j]=='W')
{
ans++;
str[i][j]='#';
dps(i,j);
}
}
printf("%d",ans);
return ;
}

POJ 2386的更多相关文章

  1. poj - 2386 Lake Counting && hdoj -1241Oil Deposits (简单dfs)

    http://poj.org/problem?id=2386 http://acm.hdu.edu.cn/showproblem.php?pid=1241 求有多少个连通子图.复杂度都是O(n*m). ...

  2. DFS----Lake Counting (poj 2386)

    Lake Counting(POJ No.2386) Description Due to recent rains, water has pooled in various places in Fa ...

  3. POJ 2386 Lake Counting DFS水水

    http://poj.org/problem?id=2386 题目大意: 有一个大小为N*M的园子,雨后积起了水.八连通的积水被认为是连接在一起的.请求出院子里共有多少水洼? 思路: 水题~直接DFS ...

  4. POJ 2386——Lake Counting(DFS)

    链接:http://poj.org/problem?id=2386 题解 #include<cstdio> #include<stack> using namespace st ...

  5. POJ 2386 Lake Counting 题解《挑战程序设计竞赛》

    地址 http://poj.org/problem?id=2386 <挑战程序设计竞赛>习题 题目描述Description Due to recent rains, water has ...

  6. POJ 2386 题解

    Lake Counting 描述 Due to recent rains, water has pooled in various places in Farmer John's field, whi ...

  7. POJ 2386 Lake Counting(深搜)

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

  8. DFS:Lake Counting(POJ 2386)

    好吧前几天一直没更新博客,主要是更新博客的确是要耗费一点精力 北大教你数水坑 最近更新博客可能就是一点旧的东西和一些水题,主要是最近对汇编感兴趣了嘻嘻嘻 这一题挺简单的,没什么难度,简单深搜 #inc ...

  9. POJ 2386 Lake Counting (水题,DFS)

    题意:给定一个n*m的矩阵,让你判断有多少个连通块. 析:用DFS搜一下即可. 代码如下: #pragma comment(linker, "/STACK:1024000000,102400 ...

随机推荐

  1. G-nav-03

    /*dele masthead.css style*/.masthead .navigation .btn.btn-masthead.btn-apply:after { content: ''; di ...

  2. DELL R720系统内存指南

    该文章摘自于:http://www.dell.com/support/article/cn/zh/cndhs1/SLN153646/zh#issue3,仅供个人作为笔记使用 PowerEdge R72 ...

  3. Struts-1和2的比较

    Struts1和Struts2都是MVC设计模式的经典应用框架,下文从代码,性能,测试,功能等方面对Struts1和Struts2进行简单比较,来看看Struts的高级版本在哪些方面进行了优化. (1 ...

  4. Learn sed using these command on Linux(流线式编辑器——sed)

    是对文件中的每一行进行处理,不会对源文件进行修改 sed --version sed '11d' sed_file sed -n '/[Bb]erry/p' sed_file (由于设置了n,所以只打 ...

  5. 【CodeForces 621A】Wet Shark and Odd and Even

    题 Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wan ...

  6. 解决启动Biee控制台乱码问题

    在安装完Biee后,大家都可以看到在程序中可以找到启动BI服务的地方 点击上图中的启动bi服务则在window系统中会弹出一个dos窗口,来显示执行启动服务的操作,如下图 上图显示的是正常情况,本人安 ...

  7. Teradata 语句简单优化

    Teradata 基本查询语言和SQL server 是一致的.有很小的区别. 功能没有SQL 全面,界面没有SQL 好看~ 1. teradata 里面经常会报一种错误: no enough spo ...

  8. UVA1629Cake slicing(记忆化搜索)

    题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=51190 紫书P305 题意分析:一个矩形蛋糕上有好多个樱桃,现在要 ...

  9. CodeForces 705A(训练水题)

    题目链接:http://codeforces.com/problemset/problem/705/A 从第三个输出中可看出规律, I hate that I love that I hate it ...

  10. 《JAVA与模式》之享元模式

    <JAVA与模式>之享元模式 在阎宏博士的<JAVA与模式>一书中开头是这样描述享元(Flyweight)模式的: Flyweight在拳击比赛中指最轻量级,即“蝇量级”或“雨 ...