Submission #637149

#TimeUsernameProblemLanguageResultExecution timeMemory
637149Ronin13Dango Maker (JOI18_dango_maker)C++14
100 / 100
594 ms123744 KiB
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;

int dp[3001][3001][3];

int main(){
    int n, m; cin >> n >> m;
    char c[n + 1][m + 1];
    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 = 1; j <= m; j++){
            if(c[i][j] == 'G'){
                if(i > 1 && i < n){
                    if(c[i - 1][j] == 'R' && c[i + 1][j]== 'W')
                        dp[i][j][1] = max(dp[i - 1][j + 1][1], dp[i - 1][j + 1][0]) + 1;
                }
                if(j > 1 && j < m){
                    if(c[i][j - 1] == 'R' && c[i][j + 1] == 'W')
                        dp[i][j][2] = max(dp[i - 1][j + 1][2], dp[i - 1][j + 1][0]) + 1;
                }
            }
            dp[i][j][0] = max({dp[i - 1][j + 1][1], dp[i - 1][j + 1][0], dp[i - 1][j + 1][2]});
        }
    }
    int ans = 0;
    for(int i = 1; i <= n + m; i++){
        if(i <= n + 1){
            ans += max({dp[i - 1][1][0], dp[i - 1][1][1], dp[i - 1][1][2]});
        }
        else ans += max({dp[n][i - n][0], dp[n][i - n][1], dp[n][i - n][2]});
    }
    cout << ans;
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...