#include <bits/stdc++.h>
using namespace std;
#define ii pair<int, int>
#define fi first
#define se second
// #define int long long
#define ll long long
#define ld double
#define mp make_pair
#define lg2 30
#define iii pair<int, ii>
#define iiii pair<ii, ii>
#define base 29
#define eps 1e-8
#define MASK(i) (1LL << (i))
#define BIT(S, i) (((S) >> (i)) & 1)
int dx[] = {0LL, 0LL, 1, -1, 1, 1, -1, -1};
int dy[] = {1, -1, 0LL, 0LL, 1, -1, 1, -1};
const int maxn = 3e3 + 5;
const int mod = 1e9 + 7;
// dp cheo
int n, m, dp[maxn][2];
char a[maxn][maxn];
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#define task "task"
if (fopen(task ".inp", "r"))
{
freopen(task ".inp", "r", stdin);
freopen(task ".out", "w", stdout);
}
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 cheo = 1; cheo <= n + m; cheo++)
{
memset(dp, 0, sizeof(dp));
int tmp = 0;
for (int j = min(m, cheo - 1), i = cheo - j; j >= 1, i <= n; j--, i++)
{
dp[j][0] = max(dp[j + 1][0], dp[j + 3][1] + (a[i][j] == 'R' && a[i][j + 1] == 'G' && a[i][j + 2] == 'W'));
dp[j][1] = max(dp[j + 1][1], dp[j + 1][0]) + (a[i][j] == 'R' && a[i + 1][j] == 'G' && a[i + 2][j] == 'W');
tmp = max(dp[j][0], dp[j][1]);
}
ans += tmp;
}
cout << ans;
cerr << endl
<< "TIME : " << clock() * 0.001 << "s" << endl;
}
Compilation message (stderr)
dango_maker.cpp: In function 'int main()':
dango_maker.cpp:32:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
32 | freopen(task ".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
dango_maker.cpp:33:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
33 | freopen(task ".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |