답안 #899303

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
899303 2024-01-05T17:10:10 Z viwlesxq Dango Maker (JOI18_dango_maker) C++17
100 / 100
393 ms 194948 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()
#define size(x) (int)x.size()

template<class S, class T>
bool chmin(S &a, const T &b) {
    return a > b && (a = b) == b;
}
template<class S, class T>
bool chmax(S &a, const T &b) {
    return a < b && (a = b) == b;
}
const int inf = 1e9 + 7;
const int INF = 1e18 + 7;
const int mod = 1e9 + 7;

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int n, m; cin >> n >> m;
    char s[n + 1][m + 1];
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            cin >> s[i][j];
        }
    }
    int res = 0;
    vector<array<int, 2>> di[n + m - 1];
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            di[i + j - 2].push_back({i, j});
        }
    }
    for (auto arr : di) {
        if (arr.empty()) continue;
        int t = size(arr);
        int dp[t][3];
        memset(dp, 0, sizeof(dp));
        for (int i = 0; i < t; ++i) {
            auto [x, y] = arr[i];
            if (i > 0)
                dp[i][0] = max({dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]});
            if (x - 1 >= 1 && x + 1 <= n && s[x - 1][y] == 'R' && s[x][y] == 'G' && s[x + 1][y] == 'W')
                dp[i][1] = (i > 0 ? max(dp[i - 1][0], dp[i - 1][1]) : 0ll) + 1;
            if (y - 1 >= 1 && y + 1 <= m && s[x][y - 1] == 'R' && s[x][y] == 'G' && s[x][y + 1] == 'W')
                dp[i][2] = (i > 0 ? max(dp[i - 1][0], dp[i - 1][2]) : 0ll) + 1;
        }
        res += max({dp[t - 1][0], dp[t - 1][1], dp[t - 1][2]});
    }
    cout << res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 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 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 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 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 604 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 456 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 460 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 448 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 344 KB Output is correct
41 Correct 1 ms 544 KB Output is correct
42 Correct 0 ms 456 KB Output is correct
43 Correct 1 ms 344 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 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 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 604 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 456 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 460 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 448 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 344 KB Output is correct
41 Correct 1 ms 544 KB Output is correct
42 Correct 0 ms 456 KB Output is correct
43 Correct 1 ms 344 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 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 624 KB Output is correct
55 Correct 1 ms 604 KB Output is correct
56 Correct 1 ms 860 KB Output is correct
57 Correct 1 ms 744 KB Output is correct
58 Correct 45 ms 22784 KB Output is correct
59 Correct 393 ms 194564 KB Output is correct
60 Correct 377 ms 194568 KB Output is correct
61 Correct 383 ms 194644 KB Output is correct
62 Correct 1 ms 604 KB Output is correct
63 Correct 356 ms 189168 KB Output is correct
64 Correct 337 ms 194608 KB Output is correct
65 Correct 333 ms 194948 KB Output is correct
66 Correct 319 ms 194712 KB Output is correct
67 Correct 327 ms 194872 KB Output is correct
68 Correct 337 ms 194640 KB Output is correct
69 Correct 337 ms 194696 KB Output is correct
70 Correct 47 ms 22612 KB Output is correct
71 Correct 36 ms 22756 KB Output is correct
72 Correct 37 ms 22608 KB Output is correct
73 Correct 35 ms 22620 KB Output is correct
74 Correct 39 ms 22784 KB Output is correct
75 Correct 37 ms 22608 KB Output is correct
76 Correct 38 ms 22784 KB Output is correct
77 Correct 37 ms 22696 KB Output is correct
78 Correct 36 ms 22784 KB Output is correct
79 Correct 37 ms 22612 KB Output is correct
80 Correct 38 ms 22616 KB Output is correct
81 Correct 36 ms 22612 KB Output is correct
82 Correct 35 ms 22608 KB Output is correct
83 Correct 36 ms 22632 KB Output is correct
84 Correct 37 ms 22608 KB Output is correct
85 Correct 41 ms 22660 KB Output is correct
86 Correct 41 ms 22624 KB Output is correct
87 Correct 37 ms 22612 KB Output is correct
88 Correct 36 ms 22612 KB Output is correct
89 Correct 35 ms 22612 KB Output is correct
90 Correct 36 ms 22872 KB Output is correct