当前位置:网站首页>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;
}
边栏推荐
- Case practice - panoramic image mosaic: feature matching method
- Digital twin demonstration project -- Talking about simple pendulum (2) vision exploration and application scenarios
- how to add square on screenshot
- EZDML逆向工程导入数据库分析实操教程
- Detailed notes on pytoch building neural network
- 我在微软的这六个月
- Use JMeter to analyze and test the lottery probability of the lottery interface
- HCIP第七天
- Multiple optimization methods print prime numbers between 100 and 200
- Zhouzhihua machine learning watermelon book chapter 2 model evaluation and selection - accuracy and model generalization evaluation method, self-help method and integrated learning
猜你喜欢

hcip第十三天笔记

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

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

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

EZDML逆向工程导入数据库分析实操教程

Robot operation continuous learning thesis (1) original text reading and Translation -- primitive generation strategy learning without catastrophic forgetting in robot operation

Detailed notes on pytoch building neural network

Avoid pitfalls and stay away from PUA in the workplace. You need to know the common routines and scripts of PUA!

DevOps随笔

我在微软的这六个月
随机推荐
how to add square on screenshot
Image feature SIFT (scale invariant feature transform)
Summary of study notes (I)
赛宁TechTalk丨攻防演练:攻击组合拳 “稳准狠”渗透
Use of ArrayList
[Beijiao] image processing: basic concepts, image enhancement, morphological processing, image segmentation
MySQL 啥时候用表锁,啥时候用行锁?
13. Unity2d horizontal version of two-way platform that can move up, down, left and right (two-way walking + movable + independent judgment) + random platform generation
Generative model and discriminant model
Eight part essay on software testing
nacos报错: ERROR Nacos failed to start, please see D:\nacos\logs\nacos.log for more details.
Use JMeter to analyze and test the lottery probability of the lottery interface
Default risk early warning preliminary competition scheme of bond issuing enterprises [AI competition]
加密熊市:有人大举扩张 有人裁员收缩
Learning dynamic Siamese network for visual object tracking full text translation
EZDML逆向工程导入数据库分析实操教程
Movie recommendation system
【MATLAB】(三)MATLAB在高等数学中的应用
1005. Maximized array sum after K negations
【线性代数】深入理解矩阵乘法、对称矩阵、正定矩阵