hdu1241 Oil Deposits
Oil Deposits
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 15084 Accepted Submission(s): 8660
#include<iostream>
#include<cstdio>
#define N 110
using namespace std; int m,n; int dir[][]={{-,-},{-,},{-,},{,-},{,},{,-},{,},{,}}; char maps[N][N]; int nx,ny; void dfs(int x,int y)
{ if(x<||x>=m||y<||y>=n)//判断当前所在位置是否合法;
return ;
if(maps[x][y]=='*')//递归结束条件;
return ;
else
{
maps[x][y]='*';
for(int i=;i<;i++)//搜索相邻的8个方向;
{
nx=x+dir[i][];
ny=y+dir[i][];
dfs(nx,ny);//进行深搜;
} }
} int main()
{
int i,j,ans; while(cin>>m>>n,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);
ans++;
}
}
}
printf("%d\n",ans);
}
return ;
}
hdu1241 Oil Deposits的更多相关文章
- HDU-1241 Oil Deposits (DFS)
Oil Deposits Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total ...
- Hdu1241 Oil Deposits (DFS)
Problem Description The GeoSurvComp geologic survey company is responsible for detecting underground ...
- HDU1241 Oil Deposits 2016-07-24 13:38 66人阅读 评论(0) 收藏
Oil Deposits Problem Description The GeoSurvComp geologic survey company is responsible for detectin ...
- HDU1241 Oil Deposits —— DFS求连通块
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1241 Oil Deposits Time Limit: 2000/1000 MS (Java/Othe ...
- 搜索专题:HDU1241 Oil Deposits
Oil Deposits Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tot ...
- HDU1241 - Oil Deposits【DFS】
GeoSurvComp地质调查公司负责探测地下石油储藏. GeoSurvComp现在在一块矩形区域探测石油,并把这个大区域分成了很多小块.他们通过专业设备,来分析每个小块中是否蕴藏石油.如果这些蕴藏石 ...
- HDU1241 Oil Deposits(dfs+连通块问题)
背景描述 ztw同志负责探测地下石油储藏.ztw现在在一块矩形区域探测石油.他通过专业设备,来分析每个小块中是否蕴藏石油.如果这些蕴藏石油的小方格相邻(横向相邻,纵向相邻,还有对角相邻),那么它们被认 ...
- Oil Deposits -----HDU1241暑假集训-搜索进阶
L - Oil Deposits Crawling in process... Crawling failed Time Limit:1000MS Memory Limit:32768KB ...
- Oil Deposits( hdu1241
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82828#problem/L Oil Deposits Time Limit:1000MS ...
随机推荐
- 哈希表工作原理 (并不特指Java中的HashTable)
1. 引言 哈希表(Hash Table)的应用近两年才在NOI中出现,作为一种高效的数据结构,它正在竞赛中发挥着越来越重要的作用. 哈希表最大的优点,就是把数据的存储和查找消耗的时 ...
- fireBug使用指南
据说,对于网页开发人员来说,Firebug是Firefox浏览器中最好的插件之一. 我最近就在学习怎么使用Firebug,网上找到一篇针对初学者的教程,感觉比较有用,就翻译了出来. ========= ...
- [Unity2D]游戏引擎介绍
由于手机游戏的流行,目前2D游戏开发的需求量也越来越大了,因此Unity3D游戏引擎也增加了2D游戏开发的支持,之前是可以通过第三方的2D游戏组件可以支持2D游戏开发,现在是官方的版本就支持了.Uni ...
- java操作FTP,实现文件上传下载删除操作
上传文件到FTP服务器: /** * Description: 向FTP服务器上传文件 * @param url FTP服务器hostname * @param port FTP服务器端口,如果默认端 ...
- SpringMVC+Spring+MyBatis整合完整版Web实例(附数据)
最近段时间正在学习Spring MVC和MyBatis的一些知识.自己也在网络上面找了一些例子来练习.但是都不是很完整.所以,今天,自己也抽空写了个完成的关于Spring MVC + Spring + ...
- java截取图片部分尺寸
package util; import java.awt.Rectangle; import java.awt.image.BufferedImage; import java.io.File; i ...
- uva146 ID码
/*极水的题...*/ #include"iostream"#include"stdio.h"#include"stdlib.h"#incl ...
- HDU 1176 经典dp
记录最晚时间 从time为2枚举到最晚时间 每个时间段的x轴节点都等于上一个时间段的可触及的最大馅饼数 #include<stdio.h> #include<string.h> ...
- HTTP POST, PUT PATCH
POST = 新增 GET = 讀取 PUT = 更新 DELETE = 刪除 PUT 会在地址栏显示参数信息,不安全! 理解POST和PUT的区别,顺便提下RESTfu 这两个方法咋一看都可以更新资 ...
- Redis 笔记与总结6 Redis 高级应用之 事务处理、持久化操作、pub_sub、虚拟内存
3.事务处理 redis 对事务的支持目前还比较简单. redis 只能保证一个 client 发起的事务中的命令可以连续的执行,而中间不会插入其他 client 的命令. 由于 redis 是单线 ...