当前位置:网站首页>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;
}
边栏推荐
- Digital twin demonstration project -- Talking about simple pendulum (2) vision exploration and application scenarios
- When does MySQL use table locks and row locks?
- [target detection] IOU (intersection and combination ratio)
- A Knight‘s Journey题解
- Do you know the use of string?
- Debug NO2 check for errors according to the process
- Vidar-Team战队专访:AS WE DO, AS YOU KNOW.
- UVA572油田 Oil Deposits题解
- Automatic test and manual test
- 45. Jumping game II
猜你喜欢

What is the NFT concept.. Fully understand NFT market, technology and cases

Do you want to have a robot that can make cartoon avatars in three steps?

What is NFT? An article to understand the concept of NFT

MS SQL Server 2019 learning
![[matlab] (III) application of MATLAB in Higher Mathematics](/img/ff/72b13fb597d5bdf3a989dd86cb6888.png)
[matlab] (III) application of MATLAB in Higher Mathematics

Super simple countdown code writing

33 introduction to sparksql, dataframe and dataset

Android kotlin uses a coroutine instead of a callback function (suspendcoroutine usage)
![[Beijiao] image processing: basic concepts, image enhancement, morphological processing, image segmentation](/img/b3/76d2bcdf4b9769fb6308b7dac9ceb5.jpg)
[Beijiao] image processing: basic concepts, image enhancement, morphological processing, image segmentation

MS SQL Server 2019 学习
随机推荐
hcip第八天笔记
Hcip day 10 notes
Debug NO2 check for errors according to the process
Hegong sky team vision training Day2 - traditional vision, opencv basic operation
Avoid pitfalls and stay away from PUA in the workplace. You need to know the common routines and scripts of PUA!
Installation and use of CONDA
The difference between session and cookie
Natural language processing Jieba
Learn - use do... While loop according to the formula e=1+1/1+ 1/2!+ 1/3!+…+ 1/n! Calculate the value of E (accuracy is 1e-6)
Super simple countdown code writing
What is NFT? An article to understand the concept of NFT
*Code understanding * common function parsing in pytoch
HCIP第七天
The vision group of Hegong University Sky team trained Day1 - machine learning, and learned to use the Yolo model
Talk about compilers based on vscode
[golang from introduction to practice] student achievement management system
Common DOS commands
Anaconda install pytorch
rbm 对比散度
生成模型与判别模型