Submission #1100518

#TimeUsernameProblemLanguageResultExecution timeMemory
1100518underwaterkillerwhaleDango Maker (JOI18_dango_maker)C++17
100 / 100
117 ms53420 KiB
//#include"holiday.h"
#include <bits/stdc++.h>
#define ll long long
#define rep(i,m,n) for(int i=(m); i<=(n); i++)
#define reb(i,m,n) for(int i=(m); i>=(n); i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair
#define fs first
#define se second
#define bit(msk, i) ((msk >> i) & 1)
#define iter(id, v) for(auto id : v)
#define pb push_back
#define SZ(v) (ll)v.size()
#define ALL(v) v.begin(),v.end()

using namespace std;

mt19937_64 rd(chrono :: steady_clock :: now ().time_since_epoch().count());
ll Rand (ll l, ll r) { return uniform_int_distribution<ll> (l, r) (rd); }

const int N = 3e3 + 7;
int Mod = 2e9 + 7;///lon
const ll INF = 2e9;
const ll BASE = 137;
const int szBL = 450;

int n, m;
char a[N][N];
int dp[N][N];

void solution () {
    cin >> n >> m;
    rep (i, 1, n) {
        string s;
        cin >> s;
        rep (j, 1, m) a[i][j] = s[j - 1];
    }
    auto dangoN = [&] (int i, int j) {
        return a[i][j - 1] == 'R' && a[i][j] == 'G' && a[i][j + 1] == 'W';
    };
    auto dangoD = [&] (int i, int j) {
        return a[i - 1][j] == 'R' && a[i][j] == 'G' && a[i + 1][j] == 'W';
    };
    int res = 0;
    rep (T, 1, n + m) {
        rep (i, 1, n) {
            int j = T - i;
            if (j > m || j <= 0) {
                rep (k, 0, 2) dp[i][k] = dp[i - 1][k];
                continue;
            }
            dp[i][0] = max({dp[i - 1][1], dp[i - 1][0], dp[i - 1][2]});
            dp[i][1] = max(dp[i - 1][0], dp[i - 1][1]) + dangoN(i, j);
            dp[i][2] = max(dp[i - 1][0], dp[i - 1][2]) + dangoD(i, j);
        }
        res += max({dp[n][0], dp[n][1], dp[n][2]});
    }
    cout << res <<"\n";
}

#define file(name) freopen(name".inp","r",stdin); \
freopen(name".out","w",stdout);
int main () {
//    file("c");
    ios_base :: sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int num_Test = 1;
//    cin >> num_Test;
    while (num_Test--)
        solution();
}
/*
no bug challenge +10

5 5
01101
10001
00110
10101
00100
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...