Submission #503239

# Submission time Handle Problem Language Result Execution time Memory
503239 2022-01-07T14:47:17 Z Kirill_Maglysh Dango Maker (JOI18_dango_maker) C++17
100 / 100
256 ms 70836 KB
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

char field[3000 + 2][3000 + 2];
short dp[3000 + 2][3000 + 2][3];

const short EMPTY = 0;
const short HORIZONTAL = 1;
const short VERTICAL = 2;

void resolve();

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    resolve();

    return 0;
}

void resolve() {
    short height;
    short width;
    cin >> height >> width;

    for (short i = 1; i <= height; ++i) {
        for (short j = 1; j <= width; ++j) {
            cin >> field[i][j];
        }
    }

    int res = 0;
    for (short i = 1; i <= height; ++i) {
        for (short j = 1; j <= width; ++j) {
            dp[i][j][EMPTY] = max(dp[i - 1][j + 1][EMPTY],
                                  max(dp[i - 1][j + 1][HORIZONTAL], dp[i - 1][j + 1][VERTICAL]));

            if (field[i - 1][j] == 'R' && field[i][j] == 'G' && field[i + 1][j] == 'W') {
                dp[i][j][VERTICAL] = 1 + max(dp[i - 1][j + 1][VERTICAL], dp[i - 1][j + 1][EMPTY]);
            }

            if (field[i][j - 1] == 'R' && field[i][j] == 'G' && field[i][j + 1] == 'W') {
                dp[i][j][HORIZONTAL] = 1 + max(dp[i - 1][j + 1][HORIZONTAL], dp[i - 1][j + 1][EMPTY]);
            }

            if (i == height || j == 1) {
                res += max(dp[i][j][EMPTY], max(dp[i][j][HORIZONTAL], dp[i][j][VERTICAL]));
            }
        }
    }

    cout << res << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 336 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 336 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Correct 0 ms 336 KB Output is correct
20 Correct 0 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 0 ms 336 KB Output is correct
24 Correct 0 ms 332 KB Output is correct
25 Correct 1 ms 328 KB Output is correct
26 Correct 0 ms 332 KB Output is correct
27 Correct 1 ms 328 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 0 ms 332 KB Output is correct
30 Correct 0 ms 332 KB Output is correct
31 Correct 0 ms 332 KB Output is correct
32 Correct 0 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 0 ms 388 KB Output is correct
35 Correct 0 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 0 ms 332 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 0 ms 332 KB Output is correct
41 Correct 0 ms 332 KB Output is correct
42 Correct 0 ms 332 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 0 ms 332 KB Output is correct
45 Correct 0 ms 336 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 0 ms 332 KB Output is correct
48 Correct 0 ms 332 KB Output is correct
49 Correct 1 ms 328 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 1 ms 388 KB Output is correct
53 Correct 0 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 336 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Correct 0 ms 336 KB Output is correct
20 Correct 0 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 0 ms 336 KB Output is correct
24 Correct 0 ms 332 KB Output is correct
25 Correct 1 ms 328 KB Output is correct
26 Correct 0 ms 332 KB Output is correct
27 Correct 1 ms 328 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 0 ms 332 KB Output is correct
30 Correct 0 ms 332 KB Output is correct
31 Correct 0 ms 332 KB Output is correct
32 Correct 0 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 0 ms 388 KB Output is correct
35 Correct 0 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 0 ms 332 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 0 ms 332 KB Output is correct
41 Correct 0 ms 332 KB Output is correct
42 Correct 0 ms 332 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 0 ms 332 KB Output is correct
45 Correct 0 ms 336 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 0 ms 332 KB Output is correct
48 Correct 0 ms 332 KB Output is correct
49 Correct 1 ms 328 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 1 ms 388 KB Output is correct
53 Correct 0 ms 332 KB Output is correct
54 Correct 0 ms 332 KB Output is correct
55 Correct 8 ms 21232 KB Output is correct
56 Correct 1 ms 336 KB Output is correct
57 Correct 6 ms 14284 KB Output is correct
58 Correct 32 ms 14116 KB Output is correct
59 Correct 242 ms 70692 KB Output is correct
60 Correct 252 ms 70708 KB Output is correct
61 Correct 256 ms 70792 KB Output is correct
62 Correct 1 ms 332 KB Output is correct
63 Correct 243 ms 70488 KB Output is correct
64 Correct 180 ms 70836 KB Output is correct
65 Correct 192 ms 70712 KB Output is correct
66 Correct 203 ms 70736 KB Output is correct
67 Correct 209 ms 70692 KB Output is correct
68 Correct 171 ms 70712 KB Output is correct
69 Correct 186 ms 70804 KB Output is correct
70 Correct 23 ms 14016 KB Output is correct
71 Correct 23 ms 14020 KB Output is correct
72 Correct 22 ms 14000 KB Output is correct
73 Correct 28 ms 14068 KB Output is correct
74 Correct 24 ms 14072 KB Output is correct
75 Correct 28 ms 14024 KB Output is correct
76 Correct 28 ms 14076 KB Output is correct
77 Correct 23 ms 14072 KB Output is correct
78 Correct 22 ms 14124 KB Output is correct
79 Correct 24 ms 14036 KB Output is correct
80 Correct 22 ms 14052 KB Output is correct
81 Correct 23 ms 14028 KB Output is correct
82 Correct 22 ms 14020 KB Output is correct
83 Correct 22 ms 14040 KB Output is correct
84 Correct 22 ms 14076 KB Output is correct
85 Correct 23 ms 14028 KB Output is correct
86 Correct 23 ms 14052 KB Output is correct
87 Correct 24 ms 14156 KB Output is correct
88 Correct 24 ms 14024 KB Output is correct
89 Correct 22 ms 14028 KB Output is correct
90 Correct 23 ms 14056 KB Output is correct