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 ...
随机推荐
- 使Gallery时设置居左显示
Gallery中的图片默认是居中显示的.可是在非常多情况下我们须要它居左显示,这样做有一个简单方法.就是把Gallery的left设置为负多少,如以下的方法: Drawable drawable=ca ...
- linux rm -rf * 文件恢复记
手太快,肠子都毁清了.本来是删除一个文件 rm path/myfile.txt结果不知为何加了个*,变成了rm path/myfile.txt *赶紧ls,发现所有代码都化为了乌有,还没提交,还没备份 ...
- [Hibernate开发之路](4)ID生成策略
一 对象关系数据库映射之Id 被映射的类必须定义相应数据库表主键字段.大多数类有一个JavaBeans风格的属性, 为每个实例包括唯一的标识. <id> 元素定义了该属性到数据库表主键字段 ...
- 常见Linux/Unix开发辅助命令什锦
很多零碎命令集锦: 1. 怎样通过命令下载ftp文件 read -s -p "Your passwd: " Passwd; wget --user=YourUserName --p ...
- iOS SDWebImage Error Domain=NSURLErrorDomain Code=-1202 “此服务器的证书无效
sdwebImage 加载网络图片的时候,如果使用的https证书未经过认证,或者证书有问题,会出现Error Domain=NSURLErrorDomain Code=-1202 "此服务 ...
- Unix下网络编程概述
这部分我要学习的是Unix下的网络编程,参照的书籍是W. Richard. Stevens的<Unix网络编程>卷一和卷二,由于本身现在从事的工作是java后台开发,对客户端-服务器的这种 ...
- 昂贵的聘礼 - poj 1062 (Dijkstra+枚举)
Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 39976 Accepted: 11596 Description 年 ...
- Hibernate 中的DetachedCriteria。
今天看到项目中在Web层使用DetachedCriteria进行多条件查询操作,如果在web层做持久层操作,事物还存在吗?这是我第一反应,于是乎就去网上查资料了.结果发现即在web层,程序员使用Det ...
- Lua string文件类型判断和内容解析
[1]文件名称类型判断和解析 local fileName = "shanxi201904npsdr1_200000.zip" print("len : " . ...
- android Notification 的使用(锁定通知栏)
近期一直在研究 android .并一边研究一边做应用.当中遇到了把程序通知常驻在 Notification 栏,而且不能被 clear 掉(就像android QQ一样)的问题.经过研究实现了其功能 ...