Submission #365772

# Submission time Handle Problem Language Result Execution time Memory
365772 2021-02-12T10:21:22 Z dolphingarlic Dango Maker (JOI18_dango_maker) C++14
100 / 100
347 ms 124920 KB
#include <bits/stdc++.h>
using namespace std;

string grid[3000];
int dp[3002][3002][3], prv = 0;

int main() {
    cin.tie(0)->sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> grid[i];
    for (int diag = 2; diag <= n + m - 2; diag++) {
        for (int i = 0; i < n; i++) {
            int j = diag - i;
            if (j < 0 || j >= m) continue;
            dp[i][j][0] = prv;
            if (j > 1 && grid[i][j] == 'W' && grid[i][j - 1] == 'G' && grid[i][j - 2] == 'R')
                dp[i][j][1] = prv + 1;
            if (i > 1 && grid[i][j] == 'W' && grid[i - 1][j] == 'G' && grid[i - 2][j] == 'R') {
                if (j == m - 1) dp[i][j][2] = prv + 1;
                else if (j == m - 2) dp[i][j][2] = max(dp[i - 1][j + 1][2], dp[i - 1][j + 1][0]) + 1;
                else dp[i][j][2] = max({dp[i - 1][j + 1][2], dp[i - 2][j + 2][2], dp[i - 2][j + 2][0]}) + 1;
            }
            prv = *max_element(dp[i][j], dp[i][j] + 3);
        }
    }
    cout << prv;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 492 KB Output is correct
6 Correct 1 ms 492 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 1 ms 492 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 492 KB Output is correct
13 Correct 1 ms 492 KB Output is correct
14 Correct 1 ms 492 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 1 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 492 KB Output is correct
6 Correct 1 ms 492 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 1 ms 492 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 492 KB Output is correct
13 Correct 1 ms 492 KB Output is correct
14 Correct 1 ms 492 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 1 ms 492 KB Output is correct
17 Correct 1 ms 492 KB Output is correct
18 Correct 1 ms 492 KB Output is correct
19 Correct 1 ms 492 KB Output is correct
20 Correct 1 ms 492 KB Output is correct
21 Correct 1 ms 492 KB Output is correct
22 Correct 1 ms 492 KB Output is correct
23 Correct 1 ms 492 KB Output is correct
24 Correct 1 ms 492 KB Output is correct
25 Correct 1 ms 492 KB Output is correct
26 Correct 1 ms 492 KB Output is correct
27 Correct 1 ms 492 KB Output is correct
28 Correct 1 ms 492 KB Output is correct
29 Correct 1 ms 492 KB Output is correct
30 Correct 1 ms 492 KB Output is correct
31 Correct 1 ms 512 KB Output is correct
32 Correct 1 ms 492 KB Output is correct
33 Correct 1 ms 492 KB Output is correct
34 Correct 1 ms 492 KB Output is correct
35 Correct 1 ms 492 KB Output is correct
36 Correct 1 ms 492 KB Output is correct
37 Correct 1 ms 492 KB Output is correct
38 Correct 1 ms 492 KB Output is correct
39 Correct 1 ms 492 KB Output is correct
40 Correct 1 ms 492 KB Output is correct
41 Correct 1 ms 492 KB Output is correct
42 Correct 1 ms 492 KB Output is correct
43 Correct 1 ms 492 KB Output is correct
44 Correct 1 ms 492 KB Output is correct
45 Correct 1 ms 492 KB Output is correct
46 Correct 1 ms 492 KB Output is correct
47 Correct 1 ms 492 KB Output is correct
48 Correct 1 ms 492 KB Output is correct
49 Correct 1 ms 492 KB Output is correct
50 Correct 1 ms 492 KB Output is correct
51 Correct 1 ms 492 KB Output is correct
52 Correct 1 ms 492 KB Output is correct
53 Correct 1 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 492 KB Output is correct
6 Correct 1 ms 492 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 1 ms 492 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 492 KB Output is correct
13 Correct 1 ms 492 KB Output is correct
14 Correct 1 ms 492 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 1 ms 492 KB Output is correct
17 Correct 1 ms 492 KB Output is correct
18 Correct 1 ms 492 KB Output is correct
19 Correct 1 ms 492 KB Output is correct
20 Correct 1 ms 492 KB Output is correct
21 Correct 1 ms 492 KB Output is correct
22 Correct 1 ms 492 KB Output is correct
23 Correct 1 ms 492 KB Output is correct
24 Correct 1 ms 492 KB Output is correct
25 Correct 1 ms 492 KB Output is correct
26 Correct 1 ms 492 KB Output is correct
27 Correct 1 ms 492 KB Output is correct
28 Correct 1 ms 492 KB Output is correct
29 Correct 1 ms 492 KB Output is correct
30 Correct 1 ms 492 KB Output is correct
31 Correct 1 ms 512 KB Output is correct
32 Correct 1 ms 492 KB Output is correct
33 Correct 1 ms 492 KB Output is correct
34 Correct 1 ms 492 KB Output is correct
35 Correct 1 ms 492 KB Output is correct
36 Correct 1 ms 492 KB Output is correct
37 Correct 1 ms 492 KB Output is correct
38 Correct 1 ms 492 KB Output is correct
39 Correct 1 ms 492 KB Output is correct
40 Correct 1 ms 492 KB Output is correct
41 Correct 1 ms 492 KB Output is correct
42 Correct 1 ms 492 KB Output is correct
43 Correct 1 ms 492 KB Output is correct
44 Correct 1 ms 492 KB Output is correct
45 Correct 1 ms 492 KB Output is correct
46 Correct 1 ms 492 KB Output is correct
47 Correct 1 ms 492 KB Output is correct
48 Correct 1 ms 492 KB Output is correct
49 Correct 1 ms 492 KB Output is correct
50 Correct 1 ms 492 KB Output is correct
51 Correct 1 ms 492 KB Output is correct
52 Correct 1 ms 492 KB Output is correct
53 Correct 1 ms 492 KB Output is correct
54 Correct 1 ms 492 KB Output is correct
55 Correct 14 ms 12652 KB Output is correct
56 Correct 1 ms 620 KB Output is correct
57 Correct 8 ms 8812 KB Output is correct
58 Correct 30 ms 18284 KB Output is correct
59 Correct 339 ms 124752 KB Output is correct
60 Correct 342 ms 124800 KB Output is correct
61 Correct 347 ms 124652 KB Output is correct
62 Correct 1 ms 492 KB Output is correct
63 Correct 326 ms 123996 KB Output is correct
64 Correct 334 ms 124920 KB Output is correct
65 Correct 327 ms 124652 KB Output is correct
66 Correct 333 ms 124796 KB Output is correct
67 Correct 328 ms 124780 KB Output is correct
68 Correct 331 ms 124780 KB Output is correct
69 Correct 329 ms 124652 KB Output is correct
70 Correct 26 ms 18284 KB Output is correct
71 Correct 29 ms 18284 KB Output is correct
72 Correct 26 ms 18284 KB Output is correct
73 Correct 25 ms 18412 KB Output is correct
74 Correct 26 ms 18284 KB Output is correct
75 Correct 26 ms 18284 KB Output is correct
76 Correct 25 ms 18284 KB Output is correct
77 Correct 26 ms 18284 KB Output is correct
78 Correct 26 ms 18284 KB Output is correct
79 Correct 26 ms 18228 KB Output is correct
80 Correct 26 ms 18284 KB Output is correct
81 Correct 26 ms 18284 KB Output is correct
82 Correct 25 ms 18284 KB Output is correct
83 Correct 26 ms 18284 KB Output is correct
84 Correct 26 ms 18156 KB Output is correct
85 Correct 26 ms 18412 KB Output is correct
86 Correct 26 ms 18284 KB Output is correct
87 Correct 27 ms 18284 KB Output is correct
88 Correct 27 ms 18204 KB Output is correct
89 Correct 26 ms 18284 KB Output is correct
90 Correct 29 ms 18284 KB Output is correct