Submission #1096880

# Submission time Handle Problem Language Result Execution time Memory
1096880 2024-10-05T10:34:05 Z Lakshya108 Dango Maker (JOI18_dango_maker) C++14
100 / 100
207 ms 68800 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vec;
const ll mxn = 1e6 + 5;
const int INF = 1e9 + 9;

void solve() {
    ll n, m;
    cin >> n >> m;
    
    vector<vector<char>> a(n+1, vector<char>(m+1));
    vector<vec> dp(mxn, vec(3, 0));

    for (ll i = 1; i <= n; i++) {
        for (ll j = 1; j <= m; j++) {
            cin >> a[i][j];
        }
    }

    ll ans = 0;

    for (ll k = 2; k <= n + m; k++) {
        for (ll i = 0; i <= n; i++)
            for (ll j = 0; j < 3; j++)
                dp[i][j] = 0;

        ll j = min(k - 1, m), i = k - j;
        int cnt = 0;

        while (i <= n && j >= 1 && j <= m) {
            dp[i][0] = max({dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]});

            if (j > 1 && j < m && a[i][j] == 'G' && a[i][j - 1] == 'R' && a[i][j + 1] == 'W') {
                dp[i][1] = max(dp[i - 1][0], dp[i - 1][1]) + 1;
            }
            if (i > 1 && i < n && a[i][j] == 'G' && a[i - 1][j] == 'R' && a[i + 1][j] == 'W') {
                dp[i][2] = max(dp[i - 1][0], dp[i - 1][2]) + 1;
            }

            i++; j--;
        }

        ans += max({dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]});
    }

    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    solve();
    return 0;
}

Compilation message

dango_maker.cpp: In function 'void solve()':
dango_maker.cpp:30:13: warning: unused variable 'cnt' [-Wunused-variable]
   30 |         int cnt = 0;
      |             ^~~
# Verdict Execution time Memory Grader output
1 Correct 39 ms 55124 KB Output is correct
2 Correct 39 ms 55132 KB Output is correct
3 Correct 40 ms 55164 KB Output is correct
4 Correct 44 ms 55220 KB Output is correct
5 Correct 39 ms 55120 KB Output is correct
6 Correct 39 ms 55120 KB Output is correct
7 Correct 39 ms 55132 KB Output is correct
8 Correct 40 ms 55124 KB Output is correct
9 Correct 46 ms 55220 KB Output is correct
10 Correct 40 ms 55124 KB Output is correct
11 Correct 39 ms 55184 KB Output is correct
12 Correct 38 ms 55132 KB Output is correct
13 Correct 39 ms 55120 KB Output is correct
14 Correct 39 ms 55208 KB Output is correct
15 Correct 39 ms 55168 KB Output is correct
16 Correct 39 ms 55132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 55124 KB Output is correct
2 Correct 39 ms 55132 KB Output is correct
3 Correct 40 ms 55164 KB Output is correct
4 Correct 44 ms 55220 KB Output is correct
5 Correct 39 ms 55120 KB Output is correct
6 Correct 39 ms 55120 KB Output is correct
7 Correct 39 ms 55132 KB Output is correct
8 Correct 40 ms 55124 KB Output is correct
9 Correct 46 ms 55220 KB Output is correct
10 Correct 40 ms 55124 KB Output is correct
11 Correct 39 ms 55184 KB Output is correct
12 Correct 38 ms 55132 KB Output is correct
13 Correct 39 ms 55120 KB Output is correct
14 Correct 39 ms 55208 KB Output is correct
15 Correct 39 ms 55168 KB Output is correct
16 Correct 39 ms 55132 KB Output is correct
17 Correct 38 ms 55132 KB Output is correct
18 Correct 48 ms 55072 KB Output is correct
19 Correct 40 ms 55132 KB Output is correct
20 Correct 40 ms 55160 KB Output is correct
21 Correct 44 ms 55124 KB Output is correct
22 Correct 41 ms 55116 KB Output is correct
23 Correct 44 ms 55108 KB Output is correct
24 Correct 43 ms 55216 KB Output is correct
25 Correct 41 ms 55132 KB Output is correct
26 Correct 48 ms 55120 KB Output is correct
27 Correct 43 ms 55180 KB Output is correct
28 Correct 51 ms 55120 KB Output is correct
29 Correct 43 ms 55132 KB Output is correct
30 Correct 40 ms 55120 KB Output is correct
31 Correct 44 ms 55120 KB Output is correct
32 Correct 48 ms 55128 KB Output is correct
33 Correct 41 ms 55380 KB Output is correct
34 Correct 41 ms 55120 KB Output is correct
35 Correct 41 ms 55124 KB Output is correct
36 Correct 40 ms 55376 KB Output is correct
37 Correct 42 ms 55124 KB Output is correct
38 Correct 40 ms 55120 KB Output is correct
39 Correct 49 ms 55120 KB Output is correct
40 Correct 39 ms 55132 KB Output is correct
41 Correct 39 ms 55124 KB Output is correct
42 Correct 39 ms 55132 KB Output is correct
43 Correct 38 ms 55136 KB Output is correct
44 Correct 39 ms 55120 KB Output is correct
45 Correct 39 ms 55132 KB Output is correct
46 Correct 39 ms 55068 KB Output is correct
47 Correct 39 ms 55132 KB Output is correct
48 Correct 39 ms 55132 KB Output is correct
49 Correct 38 ms 55120 KB Output is correct
50 Correct 44 ms 55124 KB Output is correct
51 Correct 39 ms 55056 KB Output is correct
52 Correct 39 ms 55048 KB Output is correct
53 Correct 47 ms 55120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 55124 KB Output is correct
2 Correct 39 ms 55132 KB Output is correct
3 Correct 40 ms 55164 KB Output is correct
4 Correct 44 ms 55220 KB Output is correct
5 Correct 39 ms 55120 KB Output is correct
6 Correct 39 ms 55120 KB Output is correct
7 Correct 39 ms 55132 KB Output is correct
8 Correct 40 ms 55124 KB Output is correct
9 Correct 46 ms 55220 KB Output is correct
10 Correct 40 ms 55124 KB Output is correct
11 Correct 39 ms 55184 KB Output is correct
12 Correct 38 ms 55132 KB Output is correct
13 Correct 39 ms 55120 KB Output is correct
14 Correct 39 ms 55208 KB Output is correct
15 Correct 39 ms 55168 KB Output is correct
16 Correct 39 ms 55132 KB Output is correct
17 Correct 38 ms 55132 KB Output is correct
18 Correct 48 ms 55072 KB Output is correct
19 Correct 40 ms 55132 KB Output is correct
20 Correct 40 ms 55160 KB Output is correct
21 Correct 44 ms 55124 KB Output is correct
22 Correct 41 ms 55116 KB Output is correct
23 Correct 44 ms 55108 KB Output is correct
24 Correct 43 ms 55216 KB Output is correct
25 Correct 41 ms 55132 KB Output is correct
26 Correct 48 ms 55120 KB Output is correct
27 Correct 43 ms 55180 KB Output is correct
28 Correct 51 ms 55120 KB Output is correct
29 Correct 43 ms 55132 KB Output is correct
30 Correct 40 ms 55120 KB Output is correct
31 Correct 44 ms 55120 KB Output is correct
32 Correct 48 ms 55128 KB Output is correct
33 Correct 41 ms 55380 KB Output is correct
34 Correct 41 ms 55120 KB Output is correct
35 Correct 41 ms 55124 KB Output is correct
36 Correct 40 ms 55376 KB Output is correct
37 Correct 42 ms 55124 KB Output is correct
38 Correct 40 ms 55120 KB Output is correct
39 Correct 49 ms 55120 KB Output is correct
40 Correct 39 ms 55132 KB Output is correct
41 Correct 39 ms 55124 KB Output is correct
42 Correct 39 ms 55132 KB Output is correct
43 Correct 38 ms 55136 KB Output is correct
44 Correct 39 ms 55120 KB Output is correct
45 Correct 39 ms 55132 KB Output is correct
46 Correct 39 ms 55068 KB Output is correct
47 Correct 39 ms 55132 KB Output is correct
48 Correct 39 ms 55132 KB Output is correct
49 Correct 38 ms 55120 KB Output is correct
50 Correct 44 ms 55124 KB Output is correct
51 Correct 39 ms 55056 KB Output is correct
52 Correct 39 ms 55048 KB Output is correct
53 Correct 47 ms 55120 KB Output is correct
54 Correct 39 ms 55120 KB Output is correct
55 Correct 47 ms 55376 KB Output is correct
56 Correct 40 ms 55120 KB Output is correct
57 Correct 42 ms 55132 KB Output is correct
58 Correct 58 ms 56148 KB Output is correct
59 Correct 200 ms 63984 KB Output is correct
60 Correct 202 ms 68800 KB Output is correct
61 Correct 207 ms 68692 KB Output is correct
62 Correct 48 ms 55384 KB Output is correct
63 Correct 204 ms 68360 KB Output is correct
64 Correct 161 ms 68684 KB Output is correct
65 Correct 171 ms 68768 KB Output is correct
66 Correct 160 ms 68696 KB Output is correct
67 Correct 170 ms 68688 KB Output is correct
68 Correct 162 ms 68692 KB Output is correct
69 Correct 175 ms 68688 KB Output is correct
70 Correct 62 ms 56888 KB Output is correct
71 Correct 58 ms 56920 KB Output is correct
72 Correct 59 ms 57168 KB Output is correct
73 Correct 56 ms 56912 KB Output is correct
74 Correct 58 ms 56856 KB Output is correct
75 Correct 57 ms 56912 KB Output is correct
76 Correct 63 ms 56924 KB Output is correct
77 Correct 65 ms 56856 KB Output is correct
78 Correct 58 ms 56916 KB Output is correct
79 Correct 54 ms 56920 KB Output is correct
80 Correct 53 ms 56916 KB Output is correct
81 Correct 53 ms 56912 KB Output is correct
82 Correct 56 ms 57176 KB Output is correct
83 Correct 54 ms 56916 KB Output is correct
84 Correct 57 ms 56916 KB Output is correct
85 Correct 54 ms 56832 KB Output is correct
86 Correct 59 ms 56924 KB Output is correct
87 Correct 54 ms 56836 KB Output is correct
88 Correct 54 ms 56908 KB Output is correct
89 Correct 54 ms 56924 KB Output is correct
90 Correct 54 ms 56912 KB Output is correct