#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#define max(a, b)(a > b ? a : b)
#define N 30 char maps[N][N];
int m, n, ans;
int d[][] = {{, }, {, -}, {, }, {-, }}; void DFS(int x, int y)
{
int a, b, i;
maps[x][y] = '#';//自己站的地方需要标记,以后不能再走,否则会出错
if(x < || x >= m || y < || y >= n)
return ;
for(i = ; i < ; i++)
{
a = x + d[i][];
b = y + d[i][];
if(a >= && a < m && b >= && b < n && maps[a][b] != '#')
{
maps[a][b] = '#';
ans++;
DFS(a, b);
}
}
return ;
} int main()
{
int i, j;
while(scanf("%d%d", &n, &m), m + n)
{
ans = ;//能走的包括自己站的地方
for(i = ; i < m ; i++)
scanf("%s", maps[i]);
for(i = ; i < m ; i++)
{
for(j = ; j < n ; j++)
{
if(maps[i][j] == '@')
DFS(i, j);
}
}
printf("%d\n", ans);
}
return ;
}

HDU 1312 http://acm.hdu.edu.cn/showproblem.php?pid=1312的更多相关文章

  1. HDU 4911 http://acm.hdu.edu.cn/showproblem.php?pid=4911(线段树求逆序对)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4911 解题报告: 给出一个长度为n的序列,然后给出一个k,要你求最多做k次相邻的数字交换后,逆序数最少 ...

  2. KMP(http://acm.hdu.edu.cn/showproblem.php?pid=1711)

    http://acm.hdu.edu.cn/showproblem.php?pid=1711 #include<stdio.h> #include<math.h> #inclu ...

  3. HDU-4632 http://acm.hdu.edu.cn/showproblem.php?pid=4632

    http://acm.hdu.edu.cn/showproblem.php?pid=4632 题意: 一个字符串,有多少个subsequence是回文串. 别人的题解: 用dp[i][j]表示这一段里 ...

  4. 待补 http://acm.hdu.edu.cn/showproblem.php?pid=6602

    http://acm.hdu.edu.cn/showproblem.php?pid=6602 终于能够看懂的题解: https://blog.csdn.net/qq_40871466/article/ ...

  5. HDU-1257 导弹拦截系统 http://acm.hdu.edu.cn/showproblem.php?pid=1257

    Problem Description 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高 ...

  6. http://acm.hdu.edu.cn/showproblem.php?pid=2579

    #include<stdio.h> #include<string.h> #include<queue> #define N 110 int m, n, k, x1 ...

  7. KMP应用http://acm.hdu.edu.cn/showproblem.php?pid=2594

    riemann与marjorie拼接后riemannmarjorie前缀与后缀公共部分为 rie 长度为 3(即next[l] = next[14]的值,l为拼接后的长度)但:aaaa与aa拼接后aa ...

  8. HDU 2544 最短路 http://acm.hdu.edu.cn/showproblem.php?pid=2544

    //代码: //方法1:Dijkstra's Algorithm #include<stdio.h> #include<math.h> #include<string.h ...

  9. HDU1973 http://acm.hdu.edu.cn/showproblem.php?pid=1973

    #include<stdio.h> #include<stdlib.h> #include<string.h> #include<queue> #inc ...

随机推荐

  1. Android 中Activity生命周期分析(二):从AActivity 到BActivity过程分析

    如果你没有动手去演示的话,你一定要去动手试试看,这个东西非学容易出错,面试中经常出现,好了,上代码: package com.king.review.base; import android.app. ...

  2. mac 下php运行bug

    如下所说bug在window下没有,在mac下存在. mac下的php报如下错误: fopen("data.json") Error: failed to open stream: ...

  3. CentOS5.5 正式开始安装 Oracle 11g r2(图形界面安装)

    一.下载oracle 官方网站, 可以下载最新版本 Oracle Database 11g Release http://www.oracle.com/index.html CentOS5. i386 ...

  4. JAVA操作Excel 可配置,动态 生成复杂表头 复杂的中国式报表表头

    转载:开源社区http://www.oschina.net/code/snippet_1424099_49530?p=2代码] [Java]代码 该代码实现了Excel复杂表头的生成 基于sql se ...

  5. Dapper使用在WCF上总是说Service找不到

    原因是用Console Application 做宿主的时候,创建的时候默认是Client Profile 4 ,坑爹啊.改成Net framework 4 即可.

  6. UVa 12563 Jin Ge Jin Qu hao【01背包】

    题意:给出t秒时间,n首歌分别的时间a[i],还给出一首长度为678的必须唱的劲歌金曲,问最多能够唱多少首歌(只要最后时间还剩余一秒,都可以将劲歌金曲唱完) 用dp[i]代表花费i时间时唱的歌的最大数 ...

  7. PHP适合做大型网站吗?

    1. 对递归的不良支持 递归是一种函数调用自身的机制.这是一种强大的特性可以把某些复杂的东西变得很简单.有一个使用递归的例子是快速排序(quicksort).不幸的是,PHP并不擅长递归.Zeev,一 ...

  8. Java [Leetcode 225]Implement Stack using Queues

    题目描述: Implement the following operations of a stack using queues. push(x) -- Push element x onto sta ...

  9. Oracle日常维护脚本

    1.正常停库流程     ps -ef|grep LOCAL=NO|cut -c 9-15|xargs kill -9      shutdown immediate; 2.备份数据库     bac ...

  10. GitHub开源库排名一百的简单介绍,值得收藏!

    GitHub Android Libraries Top 100 简介 本项目主要对目前 GitHub 上排名前 100 的 Android 开源库进行简单的介绍, 至于排名完全是根据 GitHub ...