Submission #736509

#TimeUsernameProblemLanguageResultExecution timeMemory
736509vjudge1Emacs (COCI20_emacs)C++14
50 / 50
1 ms340 KiB
#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 timeMemoryGrader output
Fetching results...