// ~~ icebear ~~
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
template<class T>
bool minimize(T &a, const T &b) {
if (a > b) return a = b, true;
return false;
}
template<class T>
bool maximize(T &a, const T &b) {
if (a < b) return a = b, true;
return false;
}
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORR(i,a,b) for(int i=(a); i>=(b); --i)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define RED(i, n) for(int i=(n)-1; i>=0; --i)
#define MASK(i) (1LL << (i))
#define BIT(S, i) (((S) >> (i)) & 1)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define task "icebear"
const int MOD = 1e9 + 7;
const int inf = 1e9 + 27092008;
const ll INF = 1e18 + 27092008;
const int N = 3000 + 5;
int n, m;
char a[N][N];
void init(void) {
cin >> n >> m;
FOR(i, 1, n) FOR(j, 1, m) cin >> a[i][j];
}
void process(void) {
int ans = 0;
FOR(cross, 1, n + m) {
vector<array<int, 2>> dp(m + 5, {0, 0});
int best = 0;
for(int j = min(cross - 1, m), i = cross - j; j > 0 && i <= n; j--, i++) {
if (i >= 3)
dp[j][0] = max(dp[j + 3][1], dp[j + 1][0]) + (a[i][j] == 'W' && a[i - 1][j] == 'G' && a[i - 2][j] == 'R');
if (j >= 3)
dp[j][1] = max(dp[j - 1][0], dp[j - 1][1]) + (a[i][j] == 'W' && a[i][j - 1] == 'G' && a[i][j - 2] == 'R');
maximize(best, max(dp[j][0], dp[j][1]));
}
ans += best;
}
cout << ans;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
if (fopen(task".inp", "r")) {
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
int tc = 1;
// cin >> tc;
while(tc--) {
init();
process();
}
return 0;
}
Compilation message (stderr)
dango_maker.cpp: In function 'int main()':
dango_maker.cpp:67:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
67 | freopen(task".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
dango_maker.cpp:68:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
68 | 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... |