| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1255099 | wedonttalkanymore | Dango Maker (JOI18_dango_maker) | C++20 | 1 ms | 584 KiB | 
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define pii pair<ll, ll>
#define fi first
#define se second
const ll N = 6e3 + 5, inf = 1e18, mod = 1e9 + 7, block = 320, lim = 1 << 16;
int n, m;
char a[N][N];
int dp[N][3];
bool check1(int x, int y) {
    return (a[x][y] == 'R' && a[x + 1][y] == 'G' && a[x + 2][y] == 'W');
}
bool check2(int x, int y) {
    return (a[x][y] == 'R' && a[x][y + 1] == 'G' && a[x][y + 2] == 'W');
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    if (fopen(".inp", "r")) {
        freopen(".inp", "r", stdin);
        freopen(".out", "w", stdout);
    }
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        string s;
        cin >> s;
        for (int j = 1; j <= m; j++) {
            a[i][j] = s[j - 1];
        }
    }
    int ans = 0;
    for (int i = 2; i <= n + m; i++) { // xet den o i
        memset(dp, 0, sizeof(dp));
        int res = 0;
        for (int j = min(i - 1, m), k = i - j; j > 0 && k <= n; j--, k++) {
            dp[j][0] = max(dp[j + 1][0], dp[j + 3][1]) + check2(k, j); // hang -> bo qua 2 con den con i + 3
            dp[j][1] = max(dp[j + 1][0], dp[j + 3][1]) + check1(k, j); // cot
            res = max({res, dp[j][0], dp[j][1]});
        }
        ans += res;
    }
    cout << ans;
    return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
