Submission #1173174

#TimeUsernameProblemLanguageResultExecution timeMemory
1173174tsengangDango Maker (JOI18_dango_maker)C++20
100 / 100
280 ms101988 KiB
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ertunt return
#define vodka void
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n, m;
    cin >> n >> m;
    char s[n + 1][m + 1];
    for (ll i = 1; i <= n; i++) {
        for (ll j = 1; j <= m; j++) cin >> s[i][j];
    }
    vector<ll> vis[n + m + 1];
    for (ll i = 1; i <= n; i++) {
        for (ll j = 1; j <= m; j++) {
            ll u = 0;
            if ((i > 1 and s[i - 1][j] == 'R') and s[i][j] == 'G' and (i < n and s[i + 1][j] == 'W')){
                u++;
            }
            if ((j > 1 and s[i][j - 1] == 'R') and s[i][j] == 'G' and(j < m and s[i][j + 1] == 'W')){
                u+=2;
            }
            vis[i + j].pb(u);
        }
    }
    ll ans = 0;
    vector<ll> dp(3), dp1(3);
    for (ll i = 2; i <= n + m; i++) {
        fill(dp.begin(), dp.end(), 0);
        for (auto v : vis[i]) { 
            dp1 = dp;
            fill(dp.begin(), dp.end(), 0);
            dp[0] =max({dp1[0],dp1[2],dp1[1]});
            if(v&1)dp[1] = max(dp1[0],dp1[1])+1;
            if(v&2)dp[2] = max(dp1[0],dp1[2])+1;
        }
        ans += max({dp[0], dp[1], dp[2]});
    }
    cout << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...