Submission #201771

#TimeUsernameProblemLanguageResultExecution timeMemory
201771EmmanuelACEmacs (COCI20_emacs)C++14
50 / 50
5 ms380 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double #define fi first #define se second #define pb push_back #define pii pair<int,int> #define pll pair<long long,long long> using namespace std; int n,m,ans; int dx[]={1,-1,0,0}; int dy[]={0,0,1,-1}; char mdo[110][110]; void dfs( int f , int c ){ mdo[f][c] = '.'; for(int k=0; k<4; k++){ if( f+dy[k]>=0 && f+dy[k]<n && c+dx[k]>=0 && c+dx[k]<m && mdo[ f+dy[k] ][ c+dx[k] ]=='*' ) dfs( f+dy[k] , c+dx[k] ); } return; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> m; for(int i=0; i<n; i++) for(int j=0; j<m; j++) cin >> mdo[i][j]; for(int i=0; i<n; i++) for(int j=0; j<m; j++){ if( mdo[i][j]=='*' ){ ans++; dfs( i , j ); } } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...