#include <bits/stdc++.h>
using namespace std;
template <class T> bool mini(T &x, const T &y) { return y < x ? x = y, 1 : 0; }
template <class T> bool maxi(T &x, const T &y) { return y > x ? x = y, 1 : 0; }
const int N = 3005;
int n, m, dp[N][2];
char a[N][N];
bool okr(int i, int j) { return a[i][j] == 'R' && a[i][j + 1] == 'G' && a[i][j + 2] == 'W'; }
bool okd(int i, int j) { return a[i][j] == 'R' && a[i + 1][j] == 'G' && a[i + 2][j] == 'W'; }
// rgw
// rgw
// rgw
// rgw
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++) scanf("%s", a[i] + 1);
int res = 0;
for (int d = 2; d <= n + m; d++) {
memset(dp, 0, sizeof dp);
int ans = 0;
for (int j = min(d - 1, m), i = d - j; j && i <= n; j--, i++) {
dp[j][0] = max(dp[j + 1][0], dp[j + 3][1]) + okr(i, j);
dp[j][1] = max(dp[j + 1][0], dp[j + 1][1]) + okd(i, j);
maxi(ans, max(dp[j][0], dp[j][1]));
}
res += ans;
}
cout << res;
}
Compilation message (stderr)
dango_maker.cpp: In function 'int main()':
dango_maker.cpp:23:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
23 | scanf("%d%d", &n, &m);
| ~~~~~^~~~~~~~~~~~~~~~
dango_maker.cpp:24:43: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
24 | for (int i = 1; i <= n; i++) scanf("%s", a[i] + 1);
| ~~~~~^~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |