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

             

             北大教你数水坑

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

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

#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. 如何查询Oracle中用户所有信息

    1.查看所有用户:   select * from dba_users;     select * from all_users;     select * from user_users;   2. ...

  2. bzoj 1193 贪心

    如果两点的曼哈顿距离在一定范围内时我们直接暴力搜索就可以得到答案,那么开始贪心的跳,判断两点横纵坐标的差值,差值大的方向条2,小的条1,不断做,直到曼哈顿距离较小时可以暴力求解. 备注:开始想的是确定 ...

  3. BZOJ-2186 沙拉公主的困惑 线性筛(筛筛筛)+线性推逆元

    2186: [Sdoi2008]沙拉公主的困惑 Time Limit: 10 Sec Memory Limit: 259 MB Submit: 2417 Solved: 803 [Submit][St ...

  4. POJ1141 Brackets Sequence

    Description Let us define a regular brackets sequence in the following way: 1. Empty sequence is a r ...

  5. NOIP 2012 T5 借教室 [洛谷P1083]

    题目描述 在大学期间,经常需要租借教室.大到院系举办活动,小到学习小组自习讨论,都需要 向学校申请借教室.教室的大小功能不同,借教室人的身份不同,借教室的手续也不一样. 面对海量租借教室的信息,我们自 ...

  6. Spring3.2.2之后不赞成使用queryForInt

    原来: public int getMatchCount(String username,String password){ String sql="select count(*) from ...

  7. 微型 ORM-FluentData 温故知新系列

    http://www.cnblogs.com/_popc/archive/2012/12/26/2834726.html 引言:FluentData 是微型 ORM(micro-ORM)家族的一名新成 ...

  8. AndroidManifest File Features

    http://www.android-doc.com/guide/topics/manifest/manifest-intro.html The following sections describe ...

  9. 2层Xml读取类

    配置文件 <?xml> <root> <parent name="C"> <child name="C1">Sp ...

  10. Oracle大数据常见优化查询

    [转]http://www.cnblogs.com/myhappylife/p/5006774.html 1.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的 ...