小学生玩ACM----广搜
2024-10-14 09:43:29
Oil Deposits
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7955 Accepted Submission(s): 4678
Problem 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 file 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
For each grid, output the number of distinct oil deposits. Two different pockets are part of the same oil deposit if they 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
*
3 5
*@*@*
**@**
*@*@*
1 8
@@****@*
5 5
****@
*@@*@
*@**@
@@@*@
@@**@
0 0
Sample Output
0
1
2
2
1
2
2
;
}
最新文章
- 将f2fs文件系统到磁盘
- LINUX下的拨号利器:wvdial和pppd —— 转载
- win10初体验,我的错误代码哪里去了
- php pdo错误:SQLSTATE[HY093]: Invalid parameter number: parameter was not defined
- Unity3D 几个基本动画(控制物体移动、旋转、缩放)
- Java免费开源数据库、Java嵌入式数据库、Java内存数据库
- HTML+CSS基础学习笔记(7)
- Bootstrap_Javascript_图片轮播
- (转)PHP文件没有结尾的?>;有什么好处?
- HttpClient支持使用代理服务器以及身份认证
- 在Linux下访问Windows共享目录的配置方法
- 深度神经网络(DNN)损失函数和激活函数的选择
- 集群配置虚拟主机及部署Hadoop集群碰到的问题
- Spring框架——IOC依赖注入
- 城市安全风险管理项目Postmortem结果
- 1CCTableView的使用,TableView响应和小格子tableView实现
- 【报错】java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[
- Python traceback的优雅处理
- 事件对象的属性,基于jQuery(jquery针对不同浏览器进行了兼容性的封装)
- 编程语言的分类及其优缺点,Python标准输入与输出