HDU 1312 http://acm.hdu.edu.cn/showproblem.php?pid=1312
#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的更多相关文章
- HDU 4911 http://acm.hdu.edu.cn/showproblem.php?pid=4911(线段树求逆序对)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4911 解题报告: 给出一个长度为n的序列,然后给出一个k,要你求最多做k次相邻的数字交换后,逆序数最少 ...
- 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 ...
- HDU-4632 http://acm.hdu.edu.cn/showproblem.php?pid=4632
http://acm.hdu.edu.cn/showproblem.php?pid=4632 题意: 一个字符串,有多少个subsequence是回文串. 别人的题解: 用dp[i][j]表示这一段里 ...
- 待补 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/ ...
- HDU-1257 导弹拦截系统 http://acm.hdu.edu.cn/showproblem.php?pid=1257
Problem Description 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高 ...
- 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 ...
- KMP应用http://acm.hdu.edu.cn/showproblem.php?pid=2594
riemann与marjorie拼接后riemannmarjorie前缀与后缀公共部分为 rie 长度为 3(即next[l] = next[14]的值,l为拼接后的长度)但:aaaa与aa拼接后aa ...
- HDU 2544 最短路 http://acm.hdu.edu.cn/showproblem.php?pid=2544
//代码: //方法1:Dijkstra's Algorithm #include<stdio.h> #include<math.h> #include<string.h ...
- HDU1973 http://acm.hdu.edu.cn/showproblem.php?pid=1973
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<queue> #inc ...
随机推荐
- HDU 4767 Bell(矩阵+中国剩余定理)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4767 题意:给出n.求n有多少种划分集合的方式,即bell(n) 思路: #include <i ...
- java匿名对象
java学习面向对象之匿名内部类 之前我们提到“匿名”这个字眼的时候,是在学习new对象的时候,创建匿名对象的时候用到的,之所以说是匿名,是因为直接创建对象,而没有把这个对象赋值给某个值,才称之为匿名 ...
- disable-linux-firewall-under-centos-rhel-fedora
http://www.cyberciti.biz/faq/disable-linux-firewall-under-centos-rhel-fedora/
- hdu 1243 反恐训练营(dp 最大公共子序列变形)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1243 d[i][j] 代表第i 个字符与第 j 个字符的最大的得分.,, 最大公共子序列变形 #inclu ...
- 发布 windows 10 universal app 时微软账号验证失败
具体错误:Visual Studio encountered an unexpected network error and can't contact the Microsoft account s ...
- Jqgrid入门-操作表格的数据(二)
上一篇中,Jqgrid已经可以从服务端获得数据,并显示在Grid表格中了.下面说一下,如何操作表格及其数据. jqGrid有很多方法函数,用来操作数据或者操作Grid表格本身.jq ...
- I.MX6 Android U-blox miniPCI 4G porting
/************************************************************************** * I.MX6 Android U-blox m ...
- UVA 1660 Cable TV Network 电视网络(无向图,点连通度,最大流)
题意:给一个无向图,求其点连通度?(注意输入问题) 思路: 如果只有1个点,那么输出“1”: 如果有0条边,那么输出“0”: 其他情况:用最大流解决.下面讲如何建图: 图的连通度问题是指:在图中删去部 ...
- Oracle Analyze 命令 详解
官网的链接如下: http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_4005.htm#SQLRF01105 使用DBMS ...
- javascript中常用数组函数
1.split方法——通过分隔符,将字符串分割,导出字符数组 常用于:分割IP地址,分割文件路径(上传文件时)等等 <!DOCTYPE html PUBLIC "-//W3C//DTD ...