Oil Deposits 油田问题(基础DFS深搜)

这是一道关于油田探测的算法问题,要求通过输入的二维网格数据,找出所有独立的油藏并计算其数量。每个油藏由一个或多个相邻的油口袋(用'@'表示)组成,相邻可以是水平、垂直或对角线方向。题目提供了深搜(DFS)的解题思路,通过遍历和标记已搜索区域来避免重复计数。输入包含多个网格,每个网格的大小由m和n定义,输出是每个网格中油藏的数量。示例给出了不同情况下的输入和对应输出。
摘要由CSDN通过智能技术生成

Oil Deposits 

目录

题意描述

解题思路

AC代码


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 <=

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值