很清新的一道题,搜索里面最基础的题目,深搜广搜都可以.....不过还是喜欢深搜,写起来简单》。。
////////////////////////////////////////////////
#include<queue>
#include<stdio.h>
#include<string.h>
using namespace std; const int maxn = ;
const int oo = 0xfffffff; int dir[][] = { {,},{,-},{,},{-,},
                  {,-},{,},{-,},{-,-}};
int M, N;
char G[maxn][maxn]; void DFS(int x, int y)
{
    if(x<||x==M||y<||y==N||G[x][y] != '@')
        return ;
    G[x][y] = '*';     for(int i=; i<; i++)
        DFS(x+dir[i][], y+dir[i][]);
} int main()
{
    while(scanf("%d%d", &M, &N), M+N)
    {
        int i, j, ans=;         for(i=; i<M; i++)
            scanf("%s", G[i]);         for(i=; i<M; i++)
        for(j=; j<N; j++)
        {
            if(G[i][j] == '@')
            {
                ans++;
                DFS(i, j);
            }
        }         printf("%d\n", ans);
    }     return ;

}

L - Oil Deposits的更多相关文章

  1. [kuangbin带你飞]专题一 简单搜索 - L - Oil Deposits

    #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #i ...

  2. Oil Deposits -----HDU1241暑假集训-搜索进阶

    L - Oil Deposits Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:32768KB   ...

  3. Oil Deposits( hdu1241

    http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82828#problem/L Oil Deposits Time Limit:1000MS ...

  4. hdu 1241 Oil Deposits(DFS求连通块)

    HDU 1241  Oil Deposits L -DFS Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & ...

  5. DFS(连通块) HDU 1241 Oil Deposits

    题目传送门 /* DFS:油田问题,一道经典的DFS求连通块.当初的难题,现在看上去不过如此啊 */ /************************************************ ...

  6. Oil Deposits

    Oil Deposits Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tota ...

  7. Oil Deposits(dfs)

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission( ...

  8. 2016HUAS暑假集训训练题 G - Oil Deposits

    Description The GeoSurvComp geologic survey company is responsible for detecting underground oil dep ...

  9. uva 572 oil deposits——yhx

    Oil Deposits  The GeoSurvComp geologic survey company is responsible for detecting underground oil d ...

随机推荐

  1. oracle约束条件状态

    Oracle完整性约束有一下4种: • DISABLE NOVALIDATE • ENABLE NOVALIDATE • DISABLE VALIDATE • ENABLE VALIDATE   •  ...

  2. C#中的Dictionary简介

    简介在C#中,Dictionary提供快速的基于兼职的元素查找.当你有很多元素的时候可以使用它.它包含在System.Collections.Generic名空间中. 在使用前,你必须声明它的键类型和 ...

  3. 文字排版--字体(font-family)

    我们可以使用css样式为网页中的文字设置字体.字号.颜色等样式属性.下面我们来看一个例子,下面代码实现:为网页中的文字设置字体为宋体. body{font-family:"宋体"; ...

  4. Nhibernate 智能提示 以及其他类库智能提示

    Nhibernate 的智能提示 Nhibernate.dll 放到以下路径 C:\Program Files (x86)\Reference Assemblies\Microsoft\Framewo ...

  5. 【HDU2815】【拓展BSGS】Mod Tree

    Problem Description   The picture indicates a tree, every node has 2 children.  The depth of the nod ...

  6. 2 - Annotations标注

    下面是TestNG标注和参数的一个快速预览 @BeforeSuite 被标注的方法会在这个套件的所有测试执行之前执行  @AfterSuite 被标注的方法会在这个套件的所有测试执行之后执行 @Bef ...

  7. springMVC整合jedis+redis,以注解形式使用

    前两天写过 springMVC+memcached 的整合,我从这个基础上改造一下,把redis和springmvc整合到一起. 和memcached一样,redis也有java专用的客户端,官网推荐 ...

  8. [jQuery编程挑战]004 针对选择框词典式排序

    <!DOCTYPE html> <html lang="zh"> <head> <meta charset="utf-8&quo ...

  9. 如何将eclipse里的项目发布到github

    首先,给eclipse安装上EGit 在“Help > Install new software”中添加 http://download.eclipse.org/egit/updates 两个都 ...

  10. Android与Asp.Net Web服务器的文件上传下载BUG汇总[更新]

    遇到的问题: 1.java.io.IOException: open failed: EINVAL (Invalid argument)异常,在模拟器中的sd卡创建文件夹和文件时报错 出错原因可能是: ...