Oil Deposits HDU
来源:互联网 发布:mysql unixtime 转换 编辑:程序博客网 时间:2024/06/08 15:42
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.
1 1*3 5*@*@***@***@*@*1 8@@****@*5 5 ****@*@@*@*@**@@@@*@@@**@0 0
0122
一道简单的搜索问题
#include<iostream>#include<cstring>using namespace std;const int N = 105;char pic[N][N];int m, n;void dfs(int r, int c){ if(r >= m || r < 0 || c >= n || c < 0 || pic[r][c] != '@') return; pic[r][c] = '*'; for(int i = -1; i <= 1; i++) for(int j = -1; j <= 1; j++) { if(i != 0 || j !=0) dfs(r+i, c+j); }}int main(){ while(cin>>m>>n && m) { int cnt = 0; for(int i = 0; i < m; i++) for(int j = 0; j < n; j++) cin>>pic[i][j]; for(int i = 0; i < m; i++) { for(int j = 0; j < n ; j++) { if(pic[i][j] == '@') { dfs(i, j); cnt++; } } } cout<<cnt<<endl; } return 0;}
阅读全文
0 0
- HDU 1241Oil Deposits
- HDU---1241Oil Deposits
- HDU-1244-Oil Deposits
- Hdu 1241 Oil Deposits
- Hdu 1241 - Oil Deposits
- HDU-1241:Oil Deposits
- HDU Oil Deposits
- hdu 1241 Oil Deposits
- hdu 1241 Oil Deposits
- hdu 1241 Oil Deposits
- hdu - 1241 - Oil Deposits
- HDU-1241Oil Deposits
- hdu 1241 Oil Deposits
- hdu 1241 Oil Deposits
- HDU 1241 Oil Deposits
- hdu 1241 Oil Deposits
- hdu 1241 Oil Deposits
- HDU 1241 Oil Deposits
- Linux命令基础24-userdel命令
- 产生冠军
- 51 nod 1091 线段的重叠
- 试设计一个窗口,内含一个按钮。开始运行时,按钮显示“Click Me”字样,当按钮按下时,按钮显示为“Click Me Again”字样,再按一次,则按钮显示“Click Me”字样,依此循环。
- linux locate
- Oil Deposits HDU
- Android Framework学习(十二)之获取ServiceManager
- Code Vs-problem-1057 津津的储蓄计划
- java中的TCP/IP、Http、Scoket
- Linux安装Hbase(CentOS7+Hbase1.2.5+Hadoop2.8.0)
- 2014基本贪心1003
- js中的继承详解
- USACO
- Android学习日志——第8天