很水的DFS.

为什么放上来主要是为了让自己的博客有一道DFS题解,,,

 #include<bits/stdc++.h>

 using namespace std;

 int a[][],ans,flag;

 char sx;

 void dfs(int x,int y){
if(a[x][y]==){
flag=;
a[x][y]=;
dfs(x-,y);
dfs(x+,y);
dfs(x,y-);
dfs(x,y+);
dfs(x-,y-);
dfs(x+,y-);
dfs(x-,y+);
dfs(x+,y+); } } int main(){ int n,m;
ans=;
scanf("%d%d",&n,&m); for(int i=;i<=n;i++){
for(int j=;j<=m;j++){
cin>>sx;
if(sx=='.'){
a[i][j]=;
}if(sx=='W'){
a[i][j]=;
}
}
}
for(int i=;i<=n;i++){
for(int j=;j<=m;j++){
flag=;
dfs(i,j);
if(flag==){
ans++;
}
}
}
printf("%d",ans); return ; }

[USACO10OCT]Lake Counting(DFS)的更多相关文章

  1. POJ:2386 Lake Counting(dfs)

    Lake Counting Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 40370   Accepted: 20015 D ...

  2. Poj2386 Lake Counting (DFS)

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

  3. POJ 2386——Lake Counting(DFS)

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

  4. Lake Counting(dfs)

    Description Due to recent rains, water has pooled in various places in Farmer John's field, which is ...

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

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

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

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

  7. 题解报告:poj 2386 Lake Counting(dfs求最大连通块的个数)

    Description Due to recent rains, water has pooled in various places in Farmer John's field, which is ...

  8. LeetCode Subsets II (DFS)

    题意: 给一个集合,有n个可能相同的元素,求出所有的子集(包括空集,但是不能重复). 思路: 看这个就差不多了.LEETCODE SUBSETS (DFS) class Solution { publ ...

  9. LeetCode Subsets (DFS)

    题意: 给一个集合,有n个互不相同的元素,求出所有的子集(包括空集,但是不能重复). 思路: DFS方法:由于集合中的元素是不可能出现相同的,所以不用解决相同的元素而导致重复统计. class Sol ...

随机推荐

  1. 初探postman

    第一种:安装postman 扩展程序 第二种:本地 安装postman 登陆进来postman的界面 发送第一个postman请求 将请求保存到集合 未完,待续...

  2. OpenTelemetry-可观察性的新时代

    有幸在2019KubeCon上海站听到Steve Flanders关于OpenTelemetry的演讲,之前Ops领域两个网红项目OpenTracing和OpenCensus终于走到了一起,可观察性统 ...

  3. celery 动态定时任务探索

    环境: celery 4.3 flask python 3.7 linux 需求: 动态添加定时任务,且方便维护. 解决思路: 参考django-celery 或是celery源码,将定时任务配置放置 ...

  4. 【C++】关于map的遍历 删除

    int main(int argc, char* argv[]) { map<string, string> mapData; mapData["a"] = " ...

  5. UIView 判断是否visible

    if(self.view == [(MyAppDelegate *)[[UIApplication sharedApplication] delegate].window.subviews objec ...

  6. Hibernate错误——No row with the given identifier exists

    错误 是用的是Hibernate自动建立的数据表,在进行数据库操作时,出现错误No row with the given identifier exists 解决 关系数据库一致性遭到了破坏,找到相关 ...

  7. F4NNIU 的常用 Linux 命令(2019-08-24)

    目录 F4NNIU 的常用 Linux 命令 停止防火墙 查看 IP 址 启动 deepin 的桌面 查看当前时区 查看 CPU 和内存信息 用户相关 日志 F4NNIU 的常用 Linux 命令 记 ...

  8. svn总结 标签: svn开源软件 2015-05-09 17:31 513人阅读 评论(11) 收藏

    说到SVN,就不得不说CVS,CVS 是一个C/S系统,是一个常用的代码版本控制软件.主要在开源软件管理中使用.与它相类似的代码版本控制软件有subversion.多个开发人员通过一个中心版本控制系统 ...

  9. Redis源码解析:07压缩列表

    压缩列表(ziplist)是列表键和哈希键的底层实现之一.当列表键只包含少量列表项,并且每个列表项要么是小整数值,要么是长度较短的字符串时:或者当哈希键只包含少量键值对,并且每个键值对的键和值要么是小 ...

  10. Project Euler Problem 24-Lexicographic permutations

    全排列的生成,c++的next_permutation是O(n)生成全排列的.具体的O(n)生成全排列的算法,在 布鲁迪 的那本组合数学中有讲解(课本之外,我就看过这一本组合数学),冯速老师翻译的,具 ...