Submission #440490

#TimeUsernameProblemLanguageResultExecution timeMemory
440490MahfuzAhmedEmacs (COCI20_emacs)C++14
50 / 50
1 ms344 KiB
/** * author: mahfuzz * created: 02.07.2021 **/ #include <bits/stdc++.h> using namespace std; #define debug(x) cout << '>' << #x << ':' << x << endl; #define all(p) p.begin(),p.end() typedef long long ll; const int maxn = 200; int mat[maxn][maxn]; int x[] = {0, 0, -1, 1}; int y[] = {-1, 1, 0, 0}; int main(int argc, char* argv[]){ ios_base::sync_with_stdio(0); cin.tie(nullptr); int n, m; cin >> n >> m; char grid[n + 1][m + 1]; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ cin >> grid[i][j]; } } int cnt = 0; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ if(grid[i][j] == '*'){ bool flag = false; for(int k = 0; k < 4 && !flag; k++){ int xx = i + x[k]; int yy = j + y[k]; if(mat[xx][yy] != 0){ mat[i][j] = mat[xx][yy]; flag = true; } } if(!flag){ ++cnt; mat[i][j] = cnt; } } } } cout << cnt << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...