#include <bits/stdc++.h>
#define file(name) if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
using namespace std;
const int N = 3005;
int dp[2][N][N];
char a[N][N];
int n, m;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
// file("A") else file("task");
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') {
dp[0][i][j] = (a[i - 1][j] == 'R' && a[i + 1][j] == 'W');
dp[1][i][j] = (a[i][j - 1] == 'R' && a[i][j + 1] == 'W');
if(dp[0][i - 1][j + 1] | dp[1][i - 1][j + 1]) {
dp[0][i][j] &= dp[0][i - 1][j + 1];
dp[1][i][j] &= dp[1][i - 1][j + 1];
}
ans += (dp[0][i][j] | dp[1][i][j]);
}
}
cout << ans << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |