Submission #924646

#TimeUsernameProblemLanguageResultExecution timeMemory
924646thinknoexitDango Maker (JOI18_dango_maker)C++17
100 / 100
177 ms125236 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 3000001;
char c[3030][3030];
int dp[3][3030][3030];
int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    for (int i = 1;i <= n;i++) {
        for (int j = 1;j <= m;j++) {
            cin >> c[i][j];
        }
    }
    for (int i = 1;i <= n;i++) {
        for (int j = m;j >= 1;j--) {
            dp[0][i][j] = max({ dp[0][i - 1][j + 1], dp[1][i - 1][j + 1], dp[2][i - 1][j + 1] });
            dp[1][i][j] = dp[2][i][j] = -1e9;
            if (c[i][j] == 'G' && c[i - 1][j] == 'R' && c[i + 1][j] == 'W') {
                dp[1][i][j] = max(dp[0][i - 1][j + 1], dp[1][i - 1][j + 1]) + 1;
            }
            if (c[i][j] == 'G' && c[i][j - 1] == 'R' && c[i][j + 1] == 'W') {
                dp[2][i][j] = max(dp[0][i - 1][j + 1], dp[2][i - 1][j + 1]) + 1;
            }
        }
    }
    int ans = 0;
    for (int i = 1;i <= n;i++) {
        for (int j = 1;j <= m;j++) {
            if (i == n || j == 1) {
                ans += max({ dp[0][i][j], dp[1][i][j], dp[2][i][j] });
            }
        }
    }
    cout << ans;
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...