好吧前几天一直没更新博客,主要是更新博客的确是要耗费一点精力

             

             北大教你数水坑

  最近更新博客可能就是一点旧的东西和一些水题,主要是最近对汇编感兴趣了嘻嘻嘻

  这一题挺简单的,没什么难度,简单深搜

#include <stdio.h>
#include <stdlib.h> typedef int Postion; static int Lake[][];
static int N, M; void DFS(Postion, Postion); int main(void)
{
int i, j, pool = ;
while (~scanf("%d%d",&N,&M))
{
for (i = ; i < N; i++)//读图
{
getchar();//别忘了现在是输入的是字符,一定要把回车键拿掉
for (j = ; j < M; j++)
scanf("%c", &Lake[i][j]);
} for (i = ; i < N; i++)
for (j = ; j < M; j++)
if (Lake[i][j] == 'W')
{
DFS(i, j);
pool++;
}
printf("%d\n", pool);
}
} void DFS(Postion x, Postion y)
{
int i, j;
Postion toi, toj;
Lake[x][y] = '.';//搜索过的地方就置换成. for (i = -; i <= ; i++)
for (j = -; j <= ; j++)
{
toi = x + i; toj = y + j;
if (toi >= && toi < N
&& toj >= && toj < M//坐标均在图内
&& Lake[toi][toj] == 'W'//且没进入搜索过
)
DFS(toi, toj);
}
}

DFS:Lake Counting(POJ 2386)的更多相关文章

  1. POJ 2386 Lake Counting(深搜)

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

  2. Lake Counting(POJ No.2386)

    题目描述:有一个大小为N*M的园子,八连通的积水被认为是连接在一起的.请求出园子里总共有多少水洼?(八连通指的是下图中相对w的*部分) *** *w* *** 限制条件 N,M<=100 样例 ...

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

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

  4. 图的DFS和BFS(邻接表)

    用C++实现图的DFS和BFS(邻接表) 概述   图的储存方式有邻接矩阵和邻接表储存两种.由于邻接表的实现需要用到抽象数据结构里的链表,故稍微麻烦一些.C++自带的STL可以方便的实现List,使算 ...

  5. POJ:2386 Lake Counting(dfs)

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

  6. poj 2386:Lake Counting(简单DFS深搜)

    Lake Counting Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 18201   Accepted: 9192 De ...

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

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

  8. POJ 2386 Lake Counting(搜索联通块)

    Lake Counting Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 48370 Accepted: 23775 Descr ...

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

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

随机推荐

  1. iOS之单例

    今天在看多线程同步时,突然想到了单例的同步问题.自从dispatch_once出现后,我们创建单例非常简单且安全: static dispatch_once_t pred; static Single ...

  2. bzoj 3172 后缀数组|AC自动机

    后缀数组或者AC自动机都可以,模板题. /************************************************************** Problem: 3172 Us ...

  3. mysql实用教程的数据构造

    create database XSCJ; use XSCJ; create table XS ( 学号 ) primary key not null, 姓名 ) not null, 专业名 ), 性 ...

  4. 【poj1007】 DNA Sorting

    http://poj.org/problem?id=1007 (题目链接) 题意 给出m个字符串,将其按照逆序对个数递增输出. Solution 树状数组经典应用. 代码 // poj1007 #in ...

  5. Azure怎么使用ftp登录

    1.下载配置文件 2.拷贝FTP的地址 3.查看配置文件里面的用户名和密码 4.登录

  6. [转] 计算几何模板Orz

    #include<math.h> #define MAXN 1000 #define offset 10000 #define eps 1e-8 #define PI acos(-1.0) ...

  7. UVa 437 The Tower of Babylon

    Description   Perhaps you have heard of the legend of the Tower of Babylon. Nowadays many details of ...

  8. MAC OS下安装Erlang

    这是个很大的问题,也是个很小的问题,恩.因为我最终解决方案是用了别人写的工具,名叫erlbrew: https://github.com/mrallen1/erlbrew 按照页面上的指导安装使用即可 ...

  9. Laravel教程 六:表单 Forms

    Laravel教程 六:表单 Forms 此文章为原创文章,未经同意,禁止转载. Form laravel 5.2 之后请使用 laravelcollective/html 替换 illuminate ...

  10. mysql引擎区别

    MySQL数据库引擎取决于MySQL在安装的时候是如何被编译的.要添加一个新的引擎,就必须重新编译MYSQL.在缺省情况下,MYSQL支持三个引擎:ISAM.MYISAM和HEAP.另外两种类型INN ...