Oil Deposits( hdu1241
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Description
Input
Output
Sample Input
Sample Output
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<cmath> using namespace std; #define N 110 char maps[N][N];
int m, n; void DFS(int o, int p);
int dir[][] = { {-,-},{-,},{-,},{,-},{,},{,-},{,},{,}}; int main()
{
int i, j, cou; while(cin >> m >> n, m+n)
{
cou = ; for(i = ; i < m; i++)
cin >> maps[i]; for(i = ; i < m; i++)
for(j = ; j < n; j++)
{
if(maps[i][j] == '@')
{
cou++;
DFS(i, j);
}
} cout << cou << endl;
} return ;
} void DFS(int o, int p)
{
int i, q, w; maps[o][p] = '*'; for(i = ; i < ; i++)
{
q = o + dir[i][];
w = p + dir[i][]; if(q >= && q < m && w >= && w < n && maps[q][w] == '@')
DFS(q, w);
}
}
Oil Deposits( hdu1241的更多相关文章
- HDU 1241 Oil Deposits(石油储藏)
HDU 1241 Oil Deposits(石油储藏) 00 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Probl ...
- UVA 572 -- Oil Deposits(DFS求连通块+种子填充算法)
UVA 572 -- Oil Deposits(DFS求连通块) 图也有DFS和BFS遍历,由于DFS更好写,所以一般用DFS寻找连通块. 下述代码用一个二重循环来找到当前格子的相邻8个格子,也可用常 ...
- 【HDU - 1241】Oil Deposits(dfs+染色)
Oil Deposits Descriptions: The GeoSurvComp geologic survey company is responsible for detecting unde ...
- hdu 1241:Oil Deposits(DFS)
Oil Deposits Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total ...
- ZOJ 1709 Oil Deposits(dfs,连通块个数)
Oil Deposits Time Limit: 2 Seconds Memory Limit: 65536 KB The GeoSurvComp geologic survey compa ...
- Oil Deposits (HDU - 1241 )(DFS思路 或者 BFS思路)
转载请注明出处:https://blog.csdn.net/Mercury_Lc/article/details/82706189作者:Mercury_Lc 题目链接 题解:每个点(为被修改,是#)进 ...
- 暑假集训(1)第七弹 -----Oil Deposits(Poj1562)
Description The GeoSurvComp geologic survey company is responsible for detecting underground oil dep ...
- hdu 1241 Oil Deposits(DFS求连通块)
HDU 1241 Oil Deposits L -DFS Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & ...
- hdu 1241 Oil Deposits (简单搜索)
题目: The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. ...
随机推荐
- 测开之路七十六:linux变量和环境变量
变量 赋值 variable=0,访问 $var或${var} 参数 $n 用``引住的会先执行(~键) 位置参数 环境变量/etc/profile:全局的环境变量 . bash_profile:用户 ...
- javaSE javaEE javaME的区别、有什么不同?
http://zhidao.baidu.com/link?url=oFEPOmW8BnQ0M0w0krS9DyMA5UCUufgHJWV45r9UQZ-0vp_IOx-Yl-VV0hZQ-vHXGYo ...
- Cookie 记录最后访问时间
package cn.gs.ly.servlet; import java.io.IOException; import java.io.PrintWriter; import java.util.D ...
- Recurrent Neural Network(2):BPTT and Long-term Dependencies
在RNN(1)中,我们将带有Reccurent Connection的node依照时间维度展开成了如下的形式: 在每个时刻t=0,1,2,3,...,神经网络的输出都会产生error:E0,E1,E2 ...
- Learning OSG programing---osgAnimation(2)
osg::Node* createBase(const osg::Vec3& center,float radius) { ; ; *radius; *radius; osg::Vec3 v0 ...
- Pytest+Allure2+Jenkins搭建
前置: (1)安装Python3(这里版本为3.7) (2)搭建Jenkins环境 一.安装pytest 直接使用pip安装(这里由于笔者的环境同时安装了Python2和Python3,所以在pyth ...
- 实现自己的DiscoveryClient
需要做的: DiscoveryClient能提供那些服务的服务名列表 返回指定服务对于的ServiceInstance列表 返回DiscoveryClient的顺序 返回HealthIndicator ...
- 使用redis来存储session,不同框架对session的命名规则是不一样的
今天做了一个测试,在同一个云服务器上,搭建了两个server,其中一个是用laravel框架写的,另外一个使用原生php开发的,为了提高访问的速度,使用云服务器中的redis来存储session数据, ...
- Kernel Page Global Directory (PGD) of Page table of Process created in Linux Kernel
Kernel Page Global Directory (PGD) of User process created 在早期版本: 在fork一个进程的时候,必须建立进程自己的内核页目录项(内核页目录 ...
- CSS中quotes属性以及content的open(close)-quotes属性
定义和用法 quotes 属性设置嵌套引用(embedded quotation)的引号类型. 可能的值 值 描述 none 规定 "content" 属性的 "open ...