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
 
Sample Output
0
1
2
2

;
}

最新文章

  1. 将f2fs文件系统到磁盘
  2. LINUX下的拨号利器:wvdial和pppd —— 转载
  3. win10初体验,我的错误代码哪里去了
  4. php pdo错误:SQLSTATE[HY093]: Invalid parameter number: parameter was not defined
  5. Unity3D 几个基本动画(控制物体移动、旋转、缩放)
  6. Java免费开源数据库、Java嵌入式数据库、Java内存数据库
  7. HTML+CSS基础学习笔记(7)
  8. Bootstrap_Javascript_图片轮播
  9. (转)PHP文件没有结尾的?&gt;有什么好处?
  10. HttpClient支持使用代理服务器以及身份认证
  11. 在Linux下访问Windows共享目录的配置方法
  12. 深度神经网络(DNN)损失函数和激活函数的选择
  13. 集群配置虚拟主机及部署Hadoop集群碰到的问题
  14. Spring框架——IOC依赖注入
  15. 城市安全风险管理项目Postmortem结果
  16. 1CCTableView的使用,TableView响应和小格子tableView实现
  17. 【报错】java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[
  18. Python traceback的优雅处理
  19. 事件对象的属性,基于jQuery(jquery针对不同浏览器进行了兼容性的封装)
  20. 编程语言的分类及其优缺点,Python标准输入与输出

热门文章

  1. iOS 静态类库项目的建立与使用
  2. Darwin Streaming Server 6.0.3安装、订制、插件或模块
  3. PNG文件结构分析 ---Png解析
  4. Oracle中HWM与数据库性能的探讨
  5. 最简单的基于FFMPEG的转码程序
  6. POJ 2481 Cows
  7. Android WebView常见问题的解决方案总结----例如Web page not available
  8. 《Python 学习手册4th》 第七章 字符串
  9. 软件测试技术(三)——使用因果图法进行的UI测试
  10. 向Window BCD 文件添加VHD开机启动项的相关笔记