DHU-1241 Oil Deposits
Oil Deposits
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 8515 Accepted Submission(s): 4980
*
1
2
2
思路:深搜dfs,不难,但是注意细节,积累经验。
#include<stdio.h>
char str[][];
int d[][]={,,,-, -,, -,-,,,,-,,, -,};
int m,n;
void dfs(int x,int y)
{
str[x][y] = '*';
int i,nx,ny;
for(i =;i <=;i ++)
{
nx = x+d[i][];
ny = y+d[i][];
if(nx > - && nx < m && ny > - && ny < n && str[nx][ny] == '@')
dfs(nx,ny);
}
return ;
} int main()
{
int t,k,cnt;
while(~scanf("%d%d",&m,&n)&&m)
{
cnt =;
for(t =;t < m;t ++)
scanf("%s",str[t]);
for(t =;t < m;t ++)
{
for(k =;k < n;k ++)
{
if(str[t][k] == '@')
{
dfs(t,k);
cnt++;
}
}
}
printf("%d\n",cnt);
}
return;
}
DHU-1241 Oil Deposits的更多相关文章
- HDU 1241 Oil Deposits --- 入门DFS
HDU 1241 题目大意:给定一块油田,求其连通块的数目.上下左右斜对角相邻的@属于同一个连通块. 解题思路:对每一个@进行dfs遍历并标记访问状态,一次dfs可以访问一个连通块,最后统计数量. / ...
- hdu 1241 Oil Deposits(DFS求连通块)
HDU 1241 Oil Deposits L -DFS Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & ...
- HDU 1241 Oil Deposits(石油储藏)
HDU 1241 Oil Deposits(石油储藏) 00 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Probl ...
- HDOJ(HDU).1241 Oil Deposits(DFS)
HDOJ(HDU).1241 Oil Deposits(DFS) [从零开始DFS(5)] 点我挑战题目 从零开始DFS HDOJ.1342 Lotto [从零开始DFS(0)] - DFS思想与框架 ...
- DFS(连通块) HDU 1241 Oil Deposits
题目传送门 /* DFS:油田问题,一道经典的DFS求连通块.当初的难题,现在看上去不过如此啊 */ /************************************************ ...
- hdu 1241:Oil Deposits(DFS)
Oil Deposits Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total ...
- 杭电1241 Oil Deposits
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission ...
- HDU 1241 Oil Deposits DFS(深度优先搜索) 和 BFS(广度优先搜索)
Oil Deposits Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...
- HDU 1241 Oil Deposits (DFS/BFS)
Oil Deposits Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- hdoj 1241 Oil Deposits
Oil Deposits Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
随机推荐
- apache配置文件中的项目
对于每个配置项目,有几个要素: 首先是项目名称 其次是配置的语法 再次是配置的默认值 配置所处的配置文件的位置(分区) 配置所在的模块分区(和核心是否紧密) 配置项目所在的模块 所以对于每个配置项目, ...
- HTML 多媒体
1.多媒体简介 Web 上的多媒体指的是音效.音乐.视频和动画,多媒体有多种不同的格式,它可以是听到或看到的任何内容,文字.图片.音乐.音效.录音.电影.动画等等.在互联网上,几乎在所有网站都能发现嵌 ...
- 负载均衡-多台机子session不起效:把php.ini中file改为memcache存储
一 开启memcache服务 二 修改php.ini中session配置 php/lib/php.ini session.save_handler = memcache session.save_pa ...
- PHP 自 5.2 到 5.6 中新增的功能详解
截至目前(2014.2), PHP 的最新稳定版本是 PHP5.5, 但有差不多一半的用户仍在使用已经不在维护 [注] 的 PHP5.2, 其余的一半用户在使用 PHP5.3 [注].因为 PHP 那 ...
- HTML 5 video 视频标签全属性详解
Video标签的使用 Video标签含有src.poster.preload.autoplay.loop.controls.width.height等几个属性, 以及一个内部使用的标签<sour ...
- C#中的反射 Assembly.Load() Assembly.LoadFrom()
一些关于C#反射的知识,估计也就最多达到使用API的程度,至于要深入了解,以现在的水平估计很难做到,所以下面此篇文章,以作为一个阶段的总结. 对于反射的总结,我想从以下几个方面展开,首先是反射程序集, ...
- Entity Framework Code First 数据迁移
需要在[工具 --> NuGet 程序包管理器 --> 程序包管理器控制台]中输入三个命令: Enable-Migrations (初次迁移时使用) Add-Migration [为本次迁 ...
- using namespace std
using namespace std std 是一个命名空间..不同的命名空间可以有相同的类名被定义 ..using namespace std;就是指明下面的程序使用std,如果不用这句指明的话就 ...
- Hbase案例分析(一)
Hbase应用场景: 1 随机读或者写 2 大数据上的高并发操作,比如每秒对PB级数据进行上千次操作.(查询,删除等操作) 3 读写均是非常简单的操作,比如没有join操作 Hbase Schema设 ...
- 3G? 2G? 2.5G? 4G? 与 WIFI, GPRS,CDMA 3G无线上网
首先说说无线上网有哪几种形式? WIFI, GPRS, CDMA 3G无线上网 1>wifi全称wireless fidelity,是当今使用最广的一种无线网络传输技术.实际上就是把有线网络信号 ...