很清新的一道题,搜索里面最基础的题目,深搜广搜都可以.....不过还是喜欢深搜,写起来简单》。。
////////////////////////////////////////////////
#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. 修改CMD命令窗口编码并保存方法

    我们经常出现的情况是命令行窗口乱码,默认的cmd窗口显示的中文是GBK编码,要是输出utf-8的就可能会乱码了,那么怎么修改呢. 打开的命令窗口,如果我们要修改成UTF8编码,输入命令: CHCP 6 ...

  2. 外部式css样式,写在单独的一个文件中

    外部式css样式(也可称为外联式)就是把css代码写一个单独的外部文件中,这个css样式文件以“.css”为扩展名,在<head>内(不是在<style>标签内)使用<l ...

  3. JavaScript HTML DOM

    JavaScript HTML DOM 通过 HTML DOM,可访问 JavaScript HTML 文档的所有元素. HTML DOM (文档对象模型) 当网页被加载时,浏览器会创建页面的文档对象 ...

  4. 记一个问题的AC

    今天突然做一道LCT的染色问题的时候突然想到一个两个月前一道没有AC的题目. 链接 大意是,给一个长度为10^4的序列,最多有255个不同的数字,有最多10^5次方个询问,对于每个询问 l,r 输出[ ...

  5. call/apply的第一个参数如果为null。this指向window

    call/apply是用来改变函数的作用域的,第一次参数为this,第二个参数为传输的值,例如 var a ="windowA"; var b = "windowB&qu ...

  6. Invoke()/BeginInvoke()区别

    查看MSDN如下: Control..::.Invoke          ---> 在拥有此控件的基础窗口句柄的线程上执行委托. Control..::.BeginInvoke  ---> ...

  7. rel=nofollow 是什么意思

    nofollow是什么意思? nofollow是html标签的一个属性值,Google推荐使用nofollow,告诉机器(爬虫)无需追踪目标页,是指禁止蜘蛛爬行和传递权重,但是如果你是通过sitema ...

  8. 技术大牛面试 http://www.itmian4.com/forum.php?mod=viewthread&tid=3824

    不久前,byvoid面阿里星计划的面试结果截图泄漏,引起无数IT屌丝的羡慕敬仰.看看这些牛人,NOI金牌,开源社区名人,三年级开始写Basic...在跪拜之余我们不禁要想,和这些牛人比,作为绝大部分技 ...

  9. 模块化编程AMD&CommonJS

    为什么要模块化编程 如果JS也可以像类似python,Java使用import,引入我们想要的模块,想要什么模块,就加载什么模块,可以给前端编程带来更多的便捷,结构更加清晰明了.但是,这样做有一个前提 ...

  10. map和lambda

    同事问我python里,比如一个列表: a = ['1', '2', '3'] 如何变成: b = ['1x', '2x', '3x'] 好吧,果断不知道-原来pthon中有map函数,查看帮助文档: ...