Oil Deposits -----HDU1241暑假集训-搜索进阶
Crawling in process... Crawling failed Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Description
Input
Output
Sample Input
Sample Output
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <cstring>
using namespace std;
#define INF 0xfffffff
#define maxn 15
char maps[maxn][maxn];
int m, n;
int dir[8][2] = { {-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1} };
void DFS(int x,int y)
{
maps[x][y] = '*';
for(int i=0; i<8; i++)
{
int nx = x + dir[i][0];
int ny = y + dir[i][1];
if(nx >= 0 && nx < m && ny >= 0 && ny < n && maps[nx][ny] == '@')
DFS(nx, ny);
}
}
int main()
{
int ans;
while(cin >> m >> n, m+n)
{
ans = 0;
for(int i=0; i<m; i++)
cin >> maps[i];
for(i=0; i<m; i++)
{
for(int j=0; j<n; j++)
{
if(maps[i][j] == '@')
{
ans ++;
DFS(i, j);
}
}
}
cout << ans << endl;
}
return 0;
}
Oil Deposits -----HDU1241暑假集训-搜索进阶的更多相关文章
- poj3984《迷宫问题》暑假集训-搜索进阶
K - 迷宫问题 Crawling in process... Crawling failed Time Limit:1000MS Memory Limit:65536KB 64bit ...
- HDU2612 -暑假集训-搜索进阶N
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82828#problem/N这两天总是因为一些小错误耽误时间,我希望自己可以细心点.珍惜 ...
- POJ-3126 暑假集训-搜索进阶F题
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82828#problem/F 经验就是要认真细心,要深刻理解.num #include& ...
- 暑假集训(1)第七弹 -----Oil Deposits(Poj1562)
Description The GeoSurvComp geologic survey company is responsible for detecting underground oil dep ...
- 2016HUAS暑假集训训练题 G - Oil Deposits
Description The GeoSurvComp geologic survey company is responsible for detecting underground oil dep ...
- 搜索专题:HDU1241 Oil Deposits
Oil Deposits Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tot ...
- hdu1241 Oil Deposits
Oil Deposits Time Limit: 2000/1000 MS (Java/Others) ...
- HDU 1241 Oil Deposits DFS(深度优先搜索) 和 BFS(广度优先搜索)
Oil Deposits Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...
- 不撞南墙不回头———深度优先搜索(DFS)Oil Deposits
Oil Deposits Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
随机推荐
- Ansible 安装jdk
1. 在hosts文件添一个group,里面是你需要安装jdk的ip,如: [newhosts]192.168.2.155 ansible_ssh_user=hadoop ansible_ssh_pa ...
- 在Ubuntu 16.04下安装 virtualbox 5.2
sudo sh -c 'echo "deb http://download.virtualbox.org/virtualbox/debian xenial contrib" ...
- VS2012删除选项卡菜单中的"关闭所有文档"
delete the "close all documents" item of tab menu in vs2012 Tools -> Customize -> Co ...
- 【Python3.6】之在Windows中安装Python3.6.1
由于之前做web自动化的时候,没有自己总结一篇Python3.6.1的安装步骤,这次由于学习appium自动化时换了台电脑,所以想重新总结一下. 一.安装Python3.6.1 下载Python3.6 ...
- 排序算法 python
1.先写个原始数组和测试算法是否正确,输出多次,方便计算算法运算的平均值 2.开始第一个最简单的冒泡排序 3.“”选择排序“”,跟冒泡很像,每次选最大/最小,放进新list中. 3.1发现测试test ...
- 使用Eclipse自带的Maven插件创建Web项目时报错:
问题描述: 使用Eclipse自带的Maven插件创建Web项目时报错: Could not resolve archetype org.apache.maven.archetypes:maven-a ...
- No breeds found in the signature, a signature update is recommended
cobbler 2.6.11 遇到这个问题,需要 >> cobbler signature update >> and cobblerd restart 转自: https:/ ...
- Outlook2016删不掉主账户的解决方法
控制面板>账户>邮件把配置文件删了 前两项和Outlook内部打开账户选项一样没用, 进第三个 重启Oulook的时候会提示重新建一个配置,就OK了!
- 不依任何赖第三方,单纯用vue实现Tree 树形控件
这几天接到一个需求,里面有需要做一个属性组件,找的第三方的,但是不能完全满足我的需求,有这时间,我就自己做个小轮子吧. 先看效果图(红点之前用的字体图标,是个对号,这里为了方便,用圆圈代替了选中状态, ...
- Java泛型的应用
一.泛型类 package generics; /** * 泛型类,格式:public class 类名<泛型类型1, ...> * @author zhongfg * @date 201 ...