Submission #736509

# Submission time Handle Problem Language Result Execution time Memory
736509 2023-05-05T20:25:59 Z vjudge1 Emacs (COCI20_emacs) C++14
50 / 50
1 ms 340 KB
#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
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 320 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 336 KB Output is correct