# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
238061 | Haunted_Cpp | Emacs (COCI20_emacs) | C++17 | 6 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int N = 1e2 + 5;
char g [N][N];
const int dr[] = {+1, -1, +0, +0};
const int dc[] = {+0, +0, -1, +1};
int r, c, res = 0;
void dfs (int linha, int coluna) {
if (linha < 0 || linha >= r || coluna < 0 || coluna >= c) return;
if (g[linha][coluna] == '.') return;
g[linha][coluna] = '.';
for (int i = 0; i < 4; i++) dfs (linha + dr[i], coluna + dc[i]);
}
int main () {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> r >> c;
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++) {
cin >> g[i][j];
}
}
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++) {
if (g[i][j] == '*') {
++res;
dfs (i, j);
}
}
}
cout << res << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |