很清新的一道题,搜索里面最基础的题目,深搜广搜都可以.....不过还是喜欢深搜,写起来简单》。。
////////////////////////////////////////////////
#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. 从ActionFilterAttribute向view传送数据

    [原文转载]http://www.cnblogs.com/QLeelulu/archive/2008/08/17/1269599.html 原文地址:ASP.NET MVC Tip #31 – Pas ...

  2. Redis Admin UI

    https://github.com/ServiceStackApps/RedisAdminUI 最近的v4版本不能用,需要下载v3版本,下载地址 https://github.com/Service ...

  3. 用java写bp神经网络(三)

    孔子曰,吾日三省吾身.我们如果跟程序打交道,除了一日三省吾身外,还要三日一省吾代码.看代码是否可以更简洁,更易懂,更容易扩展,更通用,算法是否可以再优化,结构是否可以再往上抽象.代码在不断的重构过程中 ...

  4. 【vc】14_网络编程_socket编程

    1.计算机网络基本知识 最简单的网络程序如图: 提示:IP地址就相当于一个公司的总机号码,端口号就相当于分机号码.在打电话时,拨通总机后,还需要转到分机上. (1)协议 ·为进行网络中的数据交换(通信 ...

  5. [LeetCode OJ] Gas Station

    问题描述: There are N gas stations along a circular route, where the amount of gas at station i is gas[i ...

  6. fish code

    <embed width="272" height="180" type="application/x-shockwave-flash" ...

  7. access_token的获取方式

      获取Access Token $appid = ""; $appsecret = ""; $url = "https://api.weixin.q ...

  8. JDK与Tomcat的联系

    如果服务器没有安装JDK或没有配置JDK环境变量,则Tomcat启动出错 报错:需要JAVA_HOME 或JRE_HOME环境变量 所以必须首先安装JDK 配置环境变量 web服务器Tomcat才能运 ...

  9. [Android1.5]TextView跑马灯效果

    from: http://www.cnblogs.com/over140/archive/2010/08/20/1804770.html 前言 这个效果在两周前搜索过,网上倒是有转载,可恨的是转载之后 ...

  10. TatukGIS - GisDefs - CheckDir 函数

    函数名称  CheckDir 所在单元  GisDefs 函数原型  function CheckDir(const _path: String): Boolean;   函数说明 如果 _path ...