当前位置:网站首页>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;
}
边栏推荐
- 多种优化方法打印100~200之间的素数
- 【线性代数】深入理解矩阵乘法、对称矩阵、正定矩阵
- Image feature Harris corner detection
- Debug No3 multi texture overlay
- [Beijiao] image processing: basic concepts, image enhancement, morphological processing, image segmentation
- Intelligent robots and intelligent systems (Professor Zheng Zheng of Dalian University of Technology) -- 2. Mobile Robot Perception
- *Project recurrence * project implementation of thesis based on contextbasedemotionrecognitionusingematicdataset
- Hegong sky team vision training day4 - traditional vision, contour recognition
- Tools for data visualization
- Natural language processing Jieba
猜你喜欢

Facing Tencent (actual combat) - Test Development - detailed explanation of interns (face experience)
![2022-07-23: given n items, each item has weight (w[i]) and value (v[i]), only two items can be selected at most, and the weight does not exceed bag. What is the maximum return value? N <= 10^5, w[i] <](/img/f4/ba2706e93f042dd8b110fac0d873c8.png)
2022-07-23: given n items, each item has weight (w[i]) and value (v[i]), only two items can be selected at most, and the weight does not exceed bag. What is the maximum return value? N <= 10^5, w[i] <

Solve the problem that Anaconda navigator cannot be opened

Postman extracts the token parameter value in the response header and sets it as an environment variable, with code attached

Hegong sky team vision training Day2 - traditional vision, opencv basic operation

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

Implement a queue with two stacks.

The vision group of Hegong University Sky team trained Day1 - machine learning, and learned to use the Yolo model

Learning to track at 100 FPS with deep progression networks

Advanced part of C language VI. file operation
随机推荐
【MATLAB】(三)MATLAB在高等数学中的应用
(dkby) DFL learning notes
CNN-VINS
Stable TTL serial port rate supported by Arduino under different dominant frequencies
Kubernetes:(一)基本概念
Install librosa using Tsinghua image
Detailed notes on pytoch building neural network
Selenium basic knowledge automatic search
2021-06-03pip error valueerror: unable to find resource t64.exe in package pip_ vendor.distlib
Anaconda install pytorch
基于VSCode聊聊编译器那些事儿
OpenGL camera and periodic review
Facing Tencent (actual combat) - Test Development - detailed explanation of interns (face experience)
Debug No1 summarizes common solutions to bugs
Why is knowledge base important? This is the best answer I've ever heard
The difference between get and post
Installation and use of CONDA
Function analysis of e-commerce website development and construction
Opencv project practice - credit card recognition
Super simple countdown code writing