当前位置:网站首页>Uva572 oil deposits problem solution
Uva572 oil deposits problem solution
2022-07-24 08:03:00 【bj_ hacker】
UVA572 Oil field Oil Deposits Answer key
subject
https://www.luogu.com.cn/problem/UVA572
Code implementation
#include<bits/stdc++.h>
using namespace std;
const int maxn=100+10;
const int dx[]={
-1,1, 0,0,-1, 1,-1,1};
const int dy[]={
0,0,-1,1,-1,-1, 1,1};
int n,m,ans;
int a[maxn][maxn],que[maxn*maxn][2];
bool vis[maxn][maxn];
inline bool inbound(int x,int y){
return x>=1&&x<=n&&y>=1&&y<=m;}
int main(){
//freopen("a.in","r",stdin);
//freopen("a.out","w",stdout);
while(1){
memset(vis,false,sizeof(vis));
ans=0;
scanf("%d%d",&n,&m);
if(n==0)break;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
char op;
scanf(" %c",&op);
if(op=='*')vis[i][j]=true;
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(!vis[i][j]){
ans++;
int head=0,tail=0;
vis[i][j]=true;
que[tail][0]=i;
que[tail++][1]=j;
while(head<tail){
int x=que[head][0],y=que[head++][1];
for(int k=0;k<8;k++){
int nx=x+dx[k],ny=y+dy[k];
if(inbound(nx,ny)&&!vis[nx][ny]){
vis[nx][ny]=true;
que[tail][0]=nx;
que[tail++][1]=ny;
}
}
}
}
}
}
printf("%d\n",ans);
}
return 0;
}
边栏推荐
- Vidar-Team战队专访:AS WE DO, AS YOU KNOW.
- DGL库中一些函数或者方法的介绍
- Common DOS commands
- Movie recommendation system
- (dkby) DFL learning notes
- 加密熊市:有人大举扩张 有人裁员收缩
- Jetson AgX Orin source change
- Introduction of some functions or methods in DGL Library
- MySQL uses explain to analyze SQL execution plans to help find performance bottlenecks
- Opencv project - credit card recognition (learning record)
猜你喜欢

避坑,职场远离PUA,PUA常见的套路与话术你得了解一下!

Kotlin coprocess analysis (III) -- understanding the context of coprocess

学习笔记总结篇(一)

Decision tree - ID3, C4.5, cart

DevOps随笔

Image feature Harris corner detection
![[linear algebra] deeply understand matrix multiplication, symmetric matrix, positive definite matrix](/img/0f/4b7e92c61814b39e9b0448c0c854ee.png)
[linear algebra] deeply understand matrix multiplication, symmetric matrix, positive definite matrix

About the solution of thinking that you download torch as a GPU version, but the result is really a CPU version

Debug No1 summarizes common solutions to bugs

Opencv project - credit card recognition (learning record)
随机推荐
mysql使用explain分析sql执行计划帮助查找性能瓶颈
[Huawei] Huawei machine test question-105
Digital twin demonstration project -- Talking about simple pendulum (3) solid model exploration
nacos报错: ERROR Nacos failed to start, please see D:\nacos\logs\nacos.log for more details.
Implement a queue with two stacks.
我在微软的这六个月
Common DOS commands
MS SQL Server 2019 learning
jmeter中JSON提取器使用
【MATLAB】(三)MATLAB在高等数学中的应用
Error reported by Nacos: error Nacos failed to start, please see d:\nacos\logs\nacos log for more details.
Summary of study notes (I)
Digital twin demonstration project -- Talking about simple pendulum (2) vision exploration and application scenarios
Generative model and discriminant model
33 introduction to sparksql, dataframe and dataset
how to add square on screenshot
Devops essay
Natural language processing hanlp
The difference between session and cookie
Avoid pitfalls and stay away from PUA in the workplace. You need to know the common routines and scripts of PUA!