Submission #388173

# Submission time Handle Problem Language Result Execution time Memory
388173 2021-04-10T10:59:30 Z blue Dango Maker (JOI18_dango_maker) C++17
100 / 100
682 ms 17988 KB
#include <iostream>
using namespace std;

char grid[3000][3000];
int N, M;

bool vert(int i, int j)
{
    if(i == 0 || i == N-1) return 0;
    if(grid[i-1][j] != 'R') return 0;
    if(grid[i][j] != 'G') return 0;
    if(grid[i+1][j] != 'W') return 0;
    return 1;
}

bool horiz(int i, int j)
{
    if(j == 0 || j == M-1) return 0;
    if(grid[i][j-1] != 'R') return 0;
    if(grid[i][j] != 'G') return 0;
    if(grid[i][j+1] != 'W') return 0;
    return 1;
}

int main()
{
    cin >> N >> M;

    for(int i = 0; i < N; i++) for(int j = 0; j < M; j++) cin >> grid[i][j];

    int res = 0;

    int H, V;
    int H1, V1;

    for(int I = 0; I < N; I++)
    {
        H = 0;
        V = 0;
        for(int s = 0; I-s >= 0 && s < M; s++)
        {
            swap(H, H1);
            swap(V, V1);

            int i = I-s;
            int j = s;

            H = max(H1, V1);
            H = max(H, H1 + horiz(i, j));

            V = max(H1, V1);
            V = max(V, V1 + vert(i, j));
        }
        // cout << H << ' ' << V << '\n';
        res += max(H, V);
    }

    for(int J = 1; J < M; J++)
    {
        H = 0;
        V = 0;

        for(int s = 0; N-1-s >= 0 && J+s < M; s++)
        {
            swap(H, H1);
            swap(V, V1);

            int i = N-1-s;
            int j = J+s;

            H = max(H1, V1);
            H = max(H, H1 + horiz(i, j));

            V = max(H1, V1);
            V = max(V, V1 + vert(i, j));
        }
        // cout << H << ' ' << V << '\n';
        res += max(H, V);
    }

    cout << res << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 208 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 0 ms 332 KB Output is correct
21 Correct 0 ms 332 KB Output is correct
22 Correct 0 ms 332 KB Output is correct
23 Correct 0 ms 332 KB Output is correct
24 Correct 0 ms 332 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 0 ms 204 KB Output is correct
27 Correct 0 ms 332 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 0 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 0 ms 332 KB Output is correct
36 Correct 0 ms 332 KB Output is correct
37 Correct 0 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 0 ms 332 KB Output is correct
40 Correct 0 ms 204 KB Output is correct
41 Correct 0 ms 332 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 0 ms 332 KB Output is correct
44 Correct 0 ms 332 KB Output is correct
45 Correct 0 ms 332 KB Output is correct
46 Correct 0 ms 332 KB Output is correct
47 Correct 0 ms 332 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 0 ms 332 KB Output is correct
50 Correct 0 ms 332 KB Output is correct
51 Correct 0 ms 336 KB Output is correct
52 Correct 0 ms 332 KB Output is correct
53 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 208 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 0 ms 332 KB Output is correct
21 Correct 0 ms 332 KB Output is correct
22 Correct 0 ms 332 KB Output is correct
23 Correct 0 ms 332 KB Output is correct
24 Correct 0 ms 332 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 0 ms 204 KB Output is correct
27 Correct 0 ms 332 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 0 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 0 ms 332 KB Output is correct
36 Correct 0 ms 332 KB Output is correct
37 Correct 0 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 0 ms 332 KB Output is correct
40 Correct 0 ms 204 KB Output is correct
41 Correct 0 ms 332 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 0 ms 332 KB Output is correct
44 Correct 0 ms 332 KB Output is correct
45 Correct 0 ms 332 KB Output is correct
46 Correct 0 ms 332 KB Output is correct
47 Correct 0 ms 332 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 0 ms 332 KB Output is correct
50 Correct 0 ms 332 KB Output is correct
51 Correct 0 ms 336 KB Output is correct
52 Correct 0 ms 332 KB Output is correct
53 Correct 1 ms 332 KB Output is correct
54 Correct 1 ms 204 KB Output is correct
55 Correct 4 ms 9036 KB Output is correct
56 Correct 2 ms 204 KB Output is correct
57 Correct 5 ms 6096 KB Output is correct
58 Correct 74 ms 3140 KB Output is correct
59 Correct 682 ms 9188 KB Output is correct
60 Correct 679 ms 17920 KB Output is correct
61 Correct 670 ms 17988 KB Output is correct
62 Correct 1 ms 204 KB Output is correct
63 Correct 653 ms 17728 KB Output is correct
64 Correct 643 ms 17964 KB Output is correct
65 Correct 627 ms 17804 KB Output is correct
66 Correct 663 ms 17820 KB Output is correct
67 Correct 634 ms 17860 KB Output is correct
68 Correct 619 ms 17860 KB Output is correct
69 Correct 627 ms 17828 KB Output is correct
70 Correct 69 ms 4164 KB Output is correct
71 Correct 68 ms 4096 KB Output is correct
72 Correct 71 ms 4156 KB Output is correct
73 Correct 68 ms 4164 KB Output is correct
74 Correct 68 ms 4156 KB Output is correct
75 Correct 74 ms 4164 KB Output is correct
76 Correct 68 ms 4164 KB Output is correct
77 Correct 69 ms 4156 KB Output is correct
78 Correct 68 ms 4172 KB Output is correct
79 Correct 70 ms 4164 KB Output is correct
80 Correct 68 ms 4196 KB Output is correct
81 Correct 70 ms 4192 KB Output is correct
82 Correct 80 ms 4164 KB Output is correct
83 Correct 69 ms 4172 KB Output is correct
84 Correct 69 ms 4096 KB Output is correct
85 Correct 71 ms 4208 KB Output is correct
86 Correct 69 ms 4148 KB Output is correct
87 Correct 69 ms 4088 KB Output is correct
88 Correct 68 ms 4180 KB Output is correct
89 Correct 69 ms 4204 KB Output is correct
90 Correct 69 ms 4136 KB Output is correct