Submission #891706

#TimeUsernameProblemLanguageResultExecution timeMemory
891706ind1vEmacs (COCI20_emacs)C++11
50 / 50
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define sz(x) (int)((x).size()) #define all(x) (x).begin(), (x).end() const int N = 102; const int dI[4] = {0, 0, -1, 1}; const int dJ[4] = {1, -1, 0, 0}; bool a[N][N], z[N][N]; int n, m, c; string s; bool check(int x, int y) { return (1 <= x && x <= n && 1 <= y && y <= m); } void ff(int x, int y) { if (!check(x, y)) return; if (z[x][y] == 1 || a[x][y] == 0) return; z[x][y] = 1; for (int i = 0; i < 4; ++i) { ff(x + dI[i], y + dJ[i]); } } int32_t main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> m; for (int i = 1; i <= n; ++i) { cin >> s; for (int j = 1; j <= m; ++j) { a[i][j] = (s[j - 1] == '*'); } } for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j) { if (a[i][j] == 1 && z[i][j] == 0) { ff(i, j); ++c; } } } cout << c; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...