답안 #891582

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
891582 2023-12-23T09:06:09 Z frostray8653 Dango Maker (JOI18_dango_maker) C++17
100 / 100
195 ms 238676 KB
#include <bits/stdc++.h>
#define int long long
#define IO ios::sync_with_stdio(0), cin.tie(0)
#define FOR(i, a, b) for (int i = a; i <= b; i++)
using namespace std;
using pii = pair<int, int>;
void dbg() {;}
template<class T, class ...U>
void dbg(T a, U ...b) { cout << a << " "; dbg(b...); }
void ent() { cout << "\n"; }
const int N = 3005;

char a[N][N];
int n, m;
bool can_x[N][N], can_y[N][N];
int dp[N][N], dpx[N][N], dpy[N][N];

signed main() {
    IO;
    
    cin >> n >> m;
    FOR(i, 1, n) FOR(j, 1, m) cin >> a[i][j];

    auto inside = [&](int x, int y) {
        return (1 <= x && x <= n && 1 <= y && y <= m);
    };
    FOR(i, 1, n) {
        FOR(j, 1, m) {
            if (inside(i - 1, j) && inside(i + 1, j) &&
                a[i - 1][j] == 'R' && a[i][j] == 'G' && a[i + 1][j] == 'W')
                can_x[i][j] = true;
            if (inside(i, j - 1) && inside(i, j + 1) &&
                a[i][j - 1] == 'R' && a[i][j] == 'G' && a[i][j + 1] == 'W')
                can_y[i][j] = true;
        }
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (can_x[i][j]) {
                dpx[i][j] = max(dpx[i - 1][j + 1], dp[i - 1][j + 1]) + 1;
            }
            if (can_y[i][j]) {
                dpy[i][j] = max(dpy[i - 1][j + 1], dp[i - 1][j + 1]) + 1;
            }
            dp[i][j] = max({dp[i - 1][j + 1], dpx[i - 1][j + 1], dpy[i - 1][j + 1]});
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
        ans += max({dp[i][1], dpx[i][1], dpy[i][1]});
    for (int j = 2; j <= m; j++)
        ans += max({dp[n][j], dpx[n][j], dpy[n][j]});
    cout << ans << "\n";

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 6488 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 6488 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 6492 KB Output is correct
18 Correct 1 ms 6492 KB Output is correct
19 Correct 1 ms 6492 KB Output is correct
20 Correct 1 ms 6492 KB Output is correct
21 Correct 1 ms 8540 KB Output is correct
22 Correct 1 ms 8540 KB Output is correct
23 Correct 1 ms 6492 KB Output is correct
24 Correct 1 ms 4444 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 0 ms 2392 KB Output is correct
27 Correct 1 ms 8540 KB Output is correct
28 Correct 1 ms 8540 KB Output is correct
29 Correct 1 ms 6492 KB Output is correct
30 Correct 1 ms 4440 KB Output is correct
31 Correct 1 ms 4444 KB Output is correct
32 Correct 1 ms 4440 KB Output is correct
33 Correct 1 ms 8540 KB Output is correct
34 Correct 1 ms 8540 KB Output is correct
35 Correct 1 ms 8540 KB Output is correct
36 Correct 1 ms 8540 KB Output is correct
37 Correct 1 ms 8540 KB Output is correct
38 Correct 1 ms 6492 KB Output is correct
39 Correct 1 ms 8536 KB Output is correct
40 Correct 1 ms 8540 KB Output is correct
41 Correct 1 ms 8540 KB Output is correct
42 Correct 1 ms 8540 KB Output is correct
43 Correct 2 ms 8536 KB Output is correct
44 Correct 1 ms 8536 KB Output is correct
45 Correct 1 ms 8540 KB Output is correct
46 Correct 2 ms 8536 KB Output is correct
47 Correct 1 ms 8536 KB Output is correct
48 Correct 1 ms 8544 KB Output is correct
49 Correct 1 ms 8548 KB Output is correct
50 Correct 1 ms 8540 KB Output is correct
51 Correct 1 ms 8540 KB Output is correct
52 Correct 1 ms 8540 KB Output is correct
53 Correct 1 ms 8540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 6488 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 6492 KB Output is correct
18 Correct 1 ms 6492 KB Output is correct
19 Correct 1 ms 6492 KB Output is correct
20 Correct 1 ms 6492 KB Output is correct
21 Correct 1 ms 8540 KB Output is correct
22 Correct 1 ms 8540 KB Output is correct
23 Correct 1 ms 6492 KB Output is correct
24 Correct 1 ms 4444 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 0 ms 2392 KB Output is correct
27 Correct 1 ms 8540 KB Output is correct
28 Correct 1 ms 8540 KB Output is correct
29 Correct 1 ms 6492 KB Output is correct
30 Correct 1 ms 4440 KB Output is correct
31 Correct 1 ms 4444 KB Output is correct
32 Correct 1 ms 4440 KB Output is correct
33 Correct 1 ms 8540 KB Output is correct
34 Correct 1 ms 8540 KB Output is correct
35 Correct 1 ms 8540 KB Output is correct
36 Correct 1 ms 8540 KB Output is correct
37 Correct 1 ms 8540 KB Output is correct
38 Correct 1 ms 6492 KB Output is correct
39 Correct 1 ms 8536 KB Output is correct
40 Correct 1 ms 8540 KB Output is correct
41 Correct 1 ms 8540 KB Output is correct
42 Correct 1 ms 8540 KB Output is correct
43 Correct 2 ms 8536 KB Output is correct
44 Correct 1 ms 8536 KB Output is correct
45 Correct 1 ms 8540 KB Output is correct
46 Correct 2 ms 8536 KB Output is correct
47 Correct 1 ms 8536 KB Output is correct
48 Correct 1 ms 8544 KB Output is correct
49 Correct 1 ms 8548 KB Output is correct
50 Correct 1 ms 8540 KB Output is correct
51 Correct 1 ms 8540 KB Output is correct
52 Correct 1 ms 8540 KB Output is correct
53 Correct 1 ms 8540 KB Output is correct
54 Correct 1 ms 4444 KB Output is correct
55 Correct 10 ms 89692 KB Output is correct
56 Correct 1 ms 6748 KB Output is correct
57 Correct 14 ms 133460 KB Output is correct
58 Correct 29 ms 87632 KB Output is correct
59 Correct 195 ms 238552 KB Output is correct
60 Correct 195 ms 238532 KB Output is correct
61 Correct 194 ms 238676 KB Output is correct
62 Correct 1 ms 4444 KB Output is correct
63 Correct 192 ms 238676 KB Output is correct
64 Correct 126 ms 238544 KB Output is correct
65 Correct 126 ms 238676 KB Output is correct
66 Correct 127 ms 238604 KB Output is correct
67 Correct 117 ms 143700 KB Output is correct
68 Correct 121 ms 151412 KB Output is correct
69 Correct 135 ms 205648 KB Output is correct
70 Correct 20 ms 87376 KB Output is correct
71 Correct 20 ms 87388 KB Output is correct
72 Correct 20 ms 87524 KB Output is correct
73 Correct 21 ms 87520 KB Output is correct
74 Correct 20 ms 87388 KB Output is correct
75 Correct 20 ms 87460 KB Output is correct
76 Correct 21 ms 87380 KB Output is correct
77 Correct 21 ms 87388 KB Output is correct
78 Correct 21 ms 87524 KB Output is correct
79 Correct 21 ms 87388 KB Output is correct
80 Correct 21 ms 87388 KB Output is correct
81 Correct 22 ms 87388 KB Output is correct
82 Correct 20 ms 87388 KB Output is correct
83 Correct 20 ms 87512 KB Output is correct
84 Correct 21 ms 87504 KB Output is correct
85 Correct 21 ms 87376 KB Output is correct
86 Correct 22 ms 87456 KB Output is correct
87 Correct 21 ms 87384 KB Output is correct
88 Correct 21 ms 87384 KB Output is correct
89 Correct 20 ms 87384 KB Output is correct
90 Correct 20 ms 87384 KB Output is correct