博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
DFS PKU 1562
阅读量:6715 次
发布时间:2019-06-25

本文共 2042 字,大约阅读时间需要 6 分钟。

简单地DFS

Oil Deposits
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 12801   Accepted: 6998

Description

The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that divides the land into numerous square plots. It then analyzes each plot separately, using sensing equipment to determine whether or not the plot contains oil. A plot containing oil is called a pocket. If two pockets are adjacent, then they are part of the same oil deposit. Oil deposits can be quite large and may contain numerous pockets. Your job is to determine how many different oil deposits are contained in a grid.

Input

The input contains one or more grids. Each grid begins with a line containing m and n, the number of rows and columns in the grid, separated by a single space. If m = 0 it signals the end of the input; otherwise 1 <= m <= 100 and 1 <= n <= 100. Following this are m lines of n characters each (not counting the end-of-line characters). Each character corresponds to one plot, and is either `*', representing the absence of oil, or `@', representing an oil pocket. 

Output

are adjacent horizontally, vertically, or diagonally. An oil deposit will not contain more than 100 pockets.

Sample Input

1 1*3 5*@*@***@***@*@*1 8@@****@*5 5 ****@*@@*@*@**@@@@*@@@**@0 0

Sample Output

0122
#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
//#include
using namespace std;#define MAXN 100 + 10char map[MAXN][MAXN];int vis[MAXN][MAXN];int m,n;//int count;int xx[8] = {-1,-1,0,1,1,1,0,-1};int yy[8] = {0,1,1,1,0,-1,-1,-1};void DFS(int x,int y){ int i; for(i=0;i<8;i++){ int dx = x+xx[i]; int dy = y+yy[i]; if(dx>=0 && dx
=0 && dy


版权声明:本文博客原创文章。博客,未经同意,不得转载。

本文转自mfrbuaa博客园博客,原文链接:http://www.cnblogs.com/mfrbuaa/p/4629750.html,如需转载请自行联系原作者

你可能感兴趣的文章
函数式编程
查看>>
spring boot mybatis没有扫描jar中的Mapper接口
查看>>
ijkPlayer 集成
查看>>
Python 文件 writelines() 方法
查看>>
背水一战 Windows 10 (76) - 控件(控件基类): Control - 基础知识, 焦点相关, 运行时获取 ControlTemplate 和 DataTemplate 中的元素...
查看>>
比特币的区块结构解析
查看>>
图像滤镜艺术---Glow Filter发光滤镜
查看>>
[离散时间信号处理学习笔记] 14. 多采样率信号处理
查看>>
create-react-app 引入 antd 及 解决 antd 样式无法显示的bug
查看>>
获取图形验证码
查看>>
值得 .NET 开发者了解的15个特性
查看>>
Fresco-Facebook的图片加载框架的使用
查看>>
Android Runtime Stats
查看>>
InstallShield卸载状态
查看>>
CentOS7 修改主机名
查看>>
小工具:天气查询 Vs自定义设置 DevGridControl中GridView排序问题 小工具:火车票查询 小工具:邮件发送 小工具:截图&简单图像处理...
查看>>
11.QT-布局管理器(Box,Grid,Form,Stacked)
查看>>
用 Anaconda 完美解决 Python2 和 python3 共存问题
查看>>
易语言飞扬学习
查看>>
Android 自定义Android ORM 框架greenDAO数据库文件的路径
查看>>