当前位置:网站首页>UVA572油田 Oil Deposits题解
UVA572油田 Oil Deposits题解
2022-07-24 07:56:00 【bj_hacker】
题目
https://www.luogu.com.cn/problem/UVA572
代码实现
#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;
}
边栏推荐
- Image feature Harris corner detection
- Selenium basic knowledge paging processing
- Selenium basic knowledge automatically login Baidu Post Bar
- A simple mobile terminal todo
- Tools for data visualization
- Digital twin demonstration project -- Talking about simple pendulum (4) IOT exploration
- hcip第九天笔记
- Common DOS commands
- Installation and use of Zen path & defect report & defect operation
- OpenGL camera and periodic review
猜你喜欢

Hcip day 7

Database system - Basic Concepts

Intelligent robots and intelligent systems (Professor Zheng Zheng of Dalian University of Technology) -- 1. robots and mobile robots

One click Copy and import of web interface data into postman

【MATLAB】(四)MATLAB在线性代数中的应用

【sklearn】PCA

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

Hcip 13th day notes

Debug No3 multi texture overlay

Use JMeter to analyze and test the lottery probability of the lottery interface
随机推荐
GBK code in idea is converted to UTF-8 format ctrl+c+v one second solution perfect solution for single code file escape
【Pytorch】Dataset_ DataLoader
Default risk early warning preliminary competition scheme of bond issuing enterprises [AI competition]
Amber tutorial A17 learning - concept
Intelligent robots and intelligent systems (Professor Zhengzheng of Dalian University of Technology) -- 4. Autonomous robots
Example of dictionary
MS SQL Server 2019 learning
Selenium basics controls the scroll bar of the browser
Multiple optimization methods print prime numbers between 100 and 200
加密熊市:有人大举扩张 有人裁员收缩
Intelligent robots and intelligent systems (Professor Zheng Zheng of Dalian University of Technology) -- 1. robots and mobile robots
Markdown basic grammar learning
RBM contrast divergence
Detailed explanation of VAO
Hcip day 9 notes
OpenGL camera and periodic review
The growth path of software testing
13.Unity2D 横版 可上下左右移动的双向平台(双向行走+可移动+单独判定)+随机平台生成
DevOps随笔
Train-clean-100 dataset