# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1057823 | 2024-08-14T06:30:24 Z | manhlinh1501 | Dango Maker (JOI18_dango_maker) | C++17 | 247 ms | 199256 KB |
#include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; using i64 = long long; const int MAXN = 3e3 + 5; #define ALL(a) (a).begin(), (a).end() #define R 0 #define D 1 int N, M; char a[MAXN][MAXN]; int dp[MAXN][MAXN][2]; bool OK[MAXN][MAXN][2]; vector<pii> g[MAXN * 2]; int maxx[MAXN * 2]; bool check(int u, int v) { return (1 <= u and u <= N and 1 <= v and v <= M); } signed main() { #define TASK "code" if (fopen(TASK ".inp", "r")) { freopen(TASK ".inp", "r", stdin); freopen(TASK ".out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); /// RGW cin >> N >> M; for(int i = 1; i <= N; i++) { for(int j = 1; j <= M; j++) cin >> a[i][j]; } for(int i = 1; i <= N; i++) { for(int j = 1; j <= M; j++) { if(a[i][j] == 'R' and a[i][j + 1] == 'G' and a[i][j + 2] == 'W') OK[i][j][R] = true; if(a[i][j] == 'R' and a[i + 1][j] == 'G' and a[i + 2][j] == 'W') OK[i][j][D] = true; } } for(int i = 1; i <= N; i++) { for(int j = 1; j <= M; j++) g[i + j].emplace_back(i, j); } for(int i = 1; i <= N + M; i++) reverse(ALL(g[i])); for(int z = N + M; z >= 1; z--) { for(auto [u, v] : g[z]) { // printf("%d %d %d\n", z, u, v); dp[u][v][R] = dp[u + 1][v - 1][R]; dp[u][v][D] = dp[u + 1][v - 1][D]; if(OK[u][v][R]) dp[u][v][R] = max(dp[u][v][R], max(dp[u + 1][v - 1][R], dp[u + 1][v - 1][D]) + 1); if(OK[u][v][D]) { dp[u][v][D] = max(dp[u][v][D], dp[u + 1][v - 1][D] + 1); if(v - 2 >= 1) dp[u][v][D] = max(dp[u][v][D], dp[u + 2][v - 2][D] + 1); if(v - 3 >= 1) dp[u][v][D] = max(dp[u][v][D], max(dp[u + 3][v - 3][D], dp[u + 3][v - 3][R]) + 1); } maxx[z] = max(maxx[z], max(dp[u][v][D], dp[u][v][R])); } } int ans = 0; for(int i = 1; i <= N + M; i++) { // cerr << maxx[i] << " "; ans += maxx[i]; } cout << ans; return (0 ^ 0); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2648 KB | Output is correct |
2 | Correct | 1 ms | 2648 KB | Output is correct |
3 | Correct | 1 ms | 2648 KB | Output is correct |
4 | Correct | 0 ms | 2652 KB | Output is correct |
5 | Correct | 0 ms | 2652 KB | Output is correct |
6 | Correct | 0 ms | 4496 KB | Output is correct |
7 | Correct | 1 ms | 4700 KB | Output is correct |
8 | Correct | 0 ms | 2652 KB | Output is correct |
9 | Correct | 1 ms | 2652 KB | Output is correct |
10 | Correct | 0 ms | 2652 KB | Output is correct |
11 | Correct | 1 ms | 4952 KB | Output is correct |
12 | Correct | 1 ms | 4700 KB | Output is correct |
13 | Correct | 1 ms | 4700 KB | Output is correct |
14 | Correct | 0 ms | 2652 KB | Output is correct |
15 | Correct | 0 ms | 2652 KB | Output is correct |
16 | Correct | 0 ms | 2652 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2648 KB | Output is correct |
2 | Correct | 1 ms | 2648 KB | Output is correct |
3 | Correct | 1 ms | 2648 KB | Output is correct |
4 | Correct | 0 ms | 2652 KB | Output is correct |
5 | Correct | 0 ms | 2652 KB | Output is correct |
6 | Correct | 0 ms | 4496 KB | Output is correct |
7 | Correct | 1 ms | 4700 KB | Output is correct |
8 | Correct | 0 ms | 2652 KB | Output is correct |
9 | Correct | 1 ms | 2652 KB | Output is correct |
10 | Correct | 0 ms | 2652 KB | Output is correct |
11 | Correct | 1 ms | 4952 KB | Output is correct |
12 | Correct | 1 ms | 4700 KB | Output is correct |
13 | Correct | 1 ms | 4700 KB | Output is correct |
14 | Correct | 0 ms | 2652 KB | Output is correct |
15 | Correct | 0 ms | 2652 KB | Output is correct |
16 | Correct | 0 ms | 2652 KB | Output is correct |
17 | Correct | 1 ms | 4700 KB | Output is correct |
18 | Correct | 0 ms | 4700 KB | Output is correct |
19 | Correct | 1 ms | 4700 KB | Output is correct |
20 | Correct | 1 ms | 4700 KB | Output is correct |
21 | Correct | 1 ms | 4700 KB | Output is correct |
22 | Correct | 1 ms | 4700 KB | Output is correct |
23 | Correct | 1 ms | 4700 KB | Output is correct |
24 | Correct | 0 ms | 4700 KB | Output is correct |
25 | Correct | 0 ms | 2652 KB | Output is correct |
26 | Correct | 0 ms | 2652 KB | Output is correct |
27 | Correct | 0 ms | 4700 KB | Output is correct |
28 | Correct | 0 ms | 4700 KB | Output is correct |
29 | Correct | 1 ms | 4700 KB | Output is correct |
30 | Correct | 1 ms | 4700 KB | Output is correct |
31 | Correct | 1 ms | 4700 KB | Output is correct |
32 | Correct | 1 ms | 4700 KB | Output is correct |
33 | Correct | 1 ms | 4700 KB | Output is correct |
34 | Correct | 1 ms | 4700 KB | Output is correct |
35 | Correct | 1 ms | 4700 KB | Output is correct |
36 | Correct | 1 ms | 4700 KB | Output is correct |
37 | Correct | 0 ms | 4700 KB | Output is correct |
38 | Correct | 0 ms | 4700 KB | Output is correct |
39 | Correct | 1 ms | 4696 KB | Output is correct |
40 | Correct | 1 ms | 4700 KB | Output is correct |
41 | Correct | 0 ms | 4700 KB | Output is correct |
42 | Correct | 0 ms | 4700 KB | Output is correct |
43 | Correct | 1 ms | 4700 KB | Output is correct |
44 | Correct | 0 ms | 4700 KB | Output is correct |
45 | Correct | 0 ms | 4700 KB | Output is correct |
46 | Correct | 1 ms | 4704 KB | Output is correct |
47 | Correct | 0 ms | 4700 KB | Output is correct |
48 | Correct | 1 ms | 4700 KB | Output is correct |
49 | Correct | 1 ms | 4700 KB | Output is correct |
50 | Correct | 1 ms | 4700 KB | Output is correct |
51 | Correct | 1 ms | 4700 KB | Output is correct |
52 | Correct | 1 ms | 4700 KB | Output is correct |
53 | Correct | 0 ms | 4700 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2648 KB | Output is correct |
2 | Correct | 1 ms | 2648 KB | Output is correct |
3 | Correct | 1 ms | 2648 KB | Output is correct |
4 | Correct | 0 ms | 2652 KB | Output is correct |
5 | Correct | 0 ms | 2652 KB | Output is correct |
6 | Correct | 0 ms | 4496 KB | Output is correct |
7 | Correct | 1 ms | 4700 KB | Output is correct |
8 | Correct | 0 ms | 2652 KB | Output is correct |
9 | Correct | 1 ms | 2652 KB | Output is correct |
10 | Correct | 0 ms | 2652 KB | Output is correct |
11 | Correct | 1 ms | 4952 KB | Output is correct |
12 | Correct | 1 ms | 4700 KB | Output is correct |
13 | Correct | 1 ms | 4700 KB | Output is correct |
14 | Correct | 0 ms | 2652 KB | Output is correct |
15 | Correct | 0 ms | 2652 KB | Output is correct |
16 | Correct | 0 ms | 2652 KB | Output is correct |
17 | Correct | 1 ms | 4700 KB | Output is correct |
18 | Correct | 0 ms | 4700 KB | Output is correct |
19 | Correct | 1 ms | 4700 KB | Output is correct |
20 | Correct | 1 ms | 4700 KB | Output is correct |
21 | Correct | 1 ms | 4700 KB | Output is correct |
22 | Correct | 1 ms | 4700 KB | Output is correct |
23 | Correct | 1 ms | 4700 KB | Output is correct |
24 | Correct | 0 ms | 4700 KB | Output is correct |
25 | Correct | 0 ms | 2652 KB | Output is correct |
26 | Correct | 0 ms | 2652 KB | Output is correct |
27 | Correct | 0 ms | 4700 KB | Output is correct |
28 | Correct | 0 ms | 4700 KB | Output is correct |
29 | Correct | 1 ms | 4700 KB | Output is correct |
30 | Correct | 1 ms | 4700 KB | Output is correct |
31 | Correct | 1 ms | 4700 KB | Output is correct |
32 | Correct | 1 ms | 4700 KB | Output is correct |
33 | Correct | 1 ms | 4700 KB | Output is correct |
34 | Correct | 1 ms | 4700 KB | Output is correct |
35 | Correct | 1 ms | 4700 KB | Output is correct |
36 | Correct | 1 ms | 4700 KB | Output is correct |
37 | Correct | 0 ms | 4700 KB | Output is correct |
38 | Correct | 0 ms | 4700 KB | Output is correct |
39 | Correct | 1 ms | 4696 KB | Output is correct |
40 | Correct | 1 ms | 4700 KB | Output is correct |
41 | Correct | 0 ms | 4700 KB | Output is correct |
42 | Correct | 0 ms | 4700 KB | Output is correct |
43 | Correct | 1 ms | 4700 KB | Output is correct |
44 | Correct | 0 ms | 4700 KB | Output is correct |
45 | Correct | 0 ms | 4700 KB | Output is correct |
46 | Correct | 1 ms | 4704 KB | Output is correct |
47 | Correct | 0 ms | 4700 KB | Output is correct |
48 | Correct | 1 ms | 4700 KB | Output is correct |
49 | Correct | 1 ms | 4700 KB | Output is correct |
50 | Correct | 1 ms | 4700 KB | Output is correct |
51 | Correct | 1 ms | 4700 KB | Output is correct |
52 | Correct | 1 ms | 4700 KB | Output is correct |
53 | Correct | 0 ms | 4700 KB | Output is correct |
54 | Correct | 1 ms | 2652 KB | Output is correct |
55 | Correct | 8 ms | 97884 KB | Output is correct |
56 | Correct | 1 ms | 4956 KB | Output is correct |
57 | Correct | 6 ms | 66652 KB | Output is correct |
58 | Correct | 27 ms | 47152 KB | Output is correct |
59 | Correct | 247 ms | 198992 KB | Output is correct |
60 | Correct | 242 ms | 199132 KB | Output is correct |
61 | Correct | 225 ms | 199092 KB | Output is correct |
62 | Correct | 1 ms | 4696 KB | Output is correct |
63 | Correct | 213 ms | 195792 KB | Output is correct |
64 | Correct | 196 ms | 199256 KB | Output is correct |
65 | Correct | 193 ms | 199008 KB | Output is correct |
66 | Correct | 190 ms | 199000 KB | Output is correct |
67 | Correct | 192 ms | 199120 KB | Output is correct |
68 | Correct | 207 ms | 199108 KB | Output is correct |
69 | Correct | 194 ms | 198992 KB | Output is correct |
70 | Correct | 24 ms | 46928 KB | Output is correct |
71 | Correct | 22 ms | 47064 KB | Output is correct |
72 | Correct | 23 ms | 47152 KB | Output is correct |
73 | Correct | 23 ms | 46928 KB | Output is correct |
74 | Correct | 23 ms | 46936 KB | Output is correct |
75 | Correct | 23 ms | 47196 KB | Output is correct |
76 | Correct | 24 ms | 46940 KB | Output is correct |
77 | Correct | 25 ms | 47056 KB | Output is correct |
78 | Correct | 23 ms | 47180 KB | Output is correct |
79 | Correct | 23 ms | 46940 KB | Output is correct |
80 | Correct | 23 ms | 47196 KB | Output is correct |
81 | Correct | 23 ms | 47192 KB | Output is correct |
82 | Correct | 23 ms | 47196 KB | Output is correct |
83 | Correct | 23 ms | 46940 KB | Output is correct |
84 | Correct | 23 ms | 47132 KB | Output is correct |
85 | Correct | 23 ms | 46932 KB | Output is correct |
86 | Correct | 23 ms | 47192 KB | Output is correct |
87 | Correct | 23 ms | 46940 KB | Output is correct |
88 | Correct | 22 ms | 47196 KB | Output is correct |
89 | Correct | 24 ms | 46932 KB | Output is correct |
90 | Correct | 23 ms | 47052 KB | Output is correct |