Submission #996315

# Submission time Handle Problem Language Result Execution time Memory
996315 2024-06-10T12:33:23 Z yanb Dango Maker (JOI18_dango_maker) C++14
100 / 100
253 ms 18264 KB
#include <bits/stdc++.h>
    
using namespace std;
    
#define int long long
#define pii pair<long long, long long>
    
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, m;
    cin >> n >> m;
    vector<vector<char>> a(n, vector<char>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    
    int ans = 0;
    for (int d = 0; d < n + m - 1; d++) {
        int x, y;
        if (d < n) x = d, y = 0;
        else x = n - 1, y = d - n + 1;

        vector<int> dpx(2), dpy(2), dp(2);
        int s = 2;

        while (x >= 0 && y < m) {
            dpx.push_back(0);
            dpy.push_back(0);
            dp.push_back(0);
            s = dpx.size();

            if (x > 0 && x < n - 1 && a[x][y] == 'G' && a[x - 1][y] == 'R' && a[x + 1][y] == 'W') {
                dpx[s - 1] = max(dpx[s - 2], dp[s - 2]) + 1;
            }
            if (y > 0 && y < m - 1 && a[x][y] == 'G' && a[x][y - 1] == 'R' && a[x][y + 1] == 'W') {
                dpy[s - 1] = max(dpy[s - 2], dp[s - 2]) + 1;
            }
            dp[s - 1] = max({dp[s - 2], dpx[s - 2], dpy[s - 2]});

            x--, y++;
        }

        ans += max({dp[s - 1], dpx[s - 1], dpy[s - 1]});
    }

    cout << ans << "\n";
}   
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 504 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 456 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 504 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 456 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 600 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 604 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 452 KB Output is correct
42 Correct 1 ms 456 KB Output is correct
43 Correct 0 ms 456 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 452 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 504 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 456 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 600 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 604 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 452 KB Output is correct
42 Correct 1 ms 456 KB Output is correct
43 Correct 0 ms 456 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 452 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 1 ms 348 KB Output is correct
54 Correct 1 ms 344 KB Output is correct
55 Correct 1 ms 604 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 2 ms 348 KB Output is correct
58 Correct 36 ms 2396 KB Output is correct
59 Correct 236 ms 18020 KB Output is correct
60 Correct 241 ms 18264 KB Output is correct
61 Correct 253 ms 18164 KB Output is correct
62 Correct 1 ms 344 KB Output is correct
63 Correct 216 ms 17492 KB Output is correct
64 Correct 202 ms 18164 KB Output is correct
65 Correct 172 ms 18160 KB Output is correct
66 Correct 183 ms 18040 KB Output is correct
67 Correct 220 ms 18020 KB Output is correct
68 Correct 212 ms 18256 KB Output is correct
69 Correct 218 ms 18164 KB Output is correct
70 Correct 20 ms 2264 KB Output is correct
71 Correct 22 ms 2396 KB Output is correct
72 Correct 15 ms 2396 KB Output is correct
73 Correct 26 ms 2396 KB Output is correct
74 Correct 16 ms 2392 KB Output is correct
75 Correct 16 ms 2256 KB Output is correct
76 Correct 16 ms 2396 KB Output is correct
77 Correct 29 ms 2396 KB Output is correct
78 Correct 16 ms 2396 KB Output is correct
79 Correct 15 ms 2396 KB Output is correct
80 Correct 23 ms 2448 KB Output is correct
81 Correct 16 ms 2396 KB Output is correct
82 Correct 18 ms 2396 KB Output is correct
83 Correct 19 ms 2344 KB Output is correct
84 Correct 17 ms 2396 KB Output is correct
85 Correct 26 ms 2396 KB Output is correct
86 Correct 16 ms 2396 KB Output is correct
87 Correct 16 ms 2396 KB Output is correct
88 Correct 29 ms 2396 KB Output is correct
89 Correct 27 ms 2344 KB Output is correct
90 Correct 16 ms 2396 KB Output is correct