#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
int n, m, cnt[2][N][N];
char a[N][N];
int main() {
cin >> n >> m;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> a[i][j];
}
}
int ans = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (a[i][j] == 'G') {
cnt[0][i][j] = (a[i][j - 1] == 'R' && a[i][j + 1] == 'W');
cnt[1][i][j] = (a[i - 1][j] == 'R' && a[i + 1][j] == 'W');
if (cnt[0][i - 1][j + 1] | cnt[1][i - 1][j + 1]) {
cnt[0][i][j] &= cnt[0][i - 1][j + 1];
cnt[1][i][j] &= cnt[1][i - 1][j + 1];
}
ans += (cnt[0][i][j] | cnt[1][i][j]);
}
}
}
cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |