# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
891706 | ind1v | Emacs (COCI20_emacs) | C++11 | 1 ms | 348 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;
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |