# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
736509 | vjudge1 | Emacs (COCI20_emacs) | C++14 | 1 ms | 340 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define N 107
#define big 1000000000000000007
int n,m;
char arr[N][N];
int var[N][N];
void bfs(int xx,int yy){
queue<pair<int,int>> q;
q.push({xx,yy});
while(q.size()){
int i=q.front().first, j=q.front().second;
q.pop();
if(var[i][j] || arr[i][j]=='.')continue;
var[i][j]=1;
if(i!=0) q.push({i-1,j});
if(i!=n-1) q.push({i+1,j});
if(j!=0)q.push({i,j-1});
if(j!=m-1)q.push({i,j+1});
}
}
int main(){
lalala;
cin>>n>>m;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++)cin>>arr[i][j];
}
int cev=0;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(var[i][j]|| arr[i][j]=='.')continue;
cev++;
bfs(i,j);
}
}
cout<<cev<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |