#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
const int N = 3001; char a[N][N];
int dp[N << 1][3];
signed main() {
#ifdef HOME
freopen("input.txt", "r", stdin);
#else
ios_base::sync_with_stdio(0); cin.tie(0);
#endif
int n, m; cin >> n >> m;
for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) cin >> a[i][j];
int ans = 0;
for (int sum = 0; sum < 2 * N; ++sum) {
for (int i = 0; i < N; ++i) for (int j = 0; j < 3; ++j) dp[i][j] = -N;
int tmp = max(0ll, sum - m + 1);
dp[tmp][0] = 0; int r = tmp;
for (int i = tmp; i <= sum && i < n; ++i) {
int j = sum - i;
int t = -N; for (int k = 0; k < 3; ++k) dp[i + 1][0] = max(dp[i + 1][0], dp[i][k]);
if (a[i][j] == 'G' && i && a[i - 1][j] == 'R' && a[i + 1][j] == 'W') dp[i + 1][1] = max(dp[i][0], dp[i][1]) + 1;
if (a[i][j] == 'G' && j && a[i][j - 1] == 'R' && a[i][j + 1] == 'W') dp[i + 1][2] = max(dp[i][0], dp[i][2]) + 1;
r = i + 1;
}
int add = 0;
for (int i = 0; i < 3; ++i) add = max(add, dp[r][i]);
ans += add;
}
cout << ans << '\n';
}
Compilation message
dango_maker.cpp: In function 'int main()':
dango_maker.cpp:24:17: warning: unused variable 't' [-Wunused-variable]
int t = -N; for (int k = 0; k < 3; ++k) dp[i + 1][0] = max(dp[i + 1][0], dp[i][k]);
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
552 KB |
Output is correct |
2 |
Correct |
29 ms |
504 KB |
Output is correct |
3 |
Correct |
29 ms |
516 KB |
Output is correct |
4 |
Correct |
29 ms |
504 KB |
Output is correct |
5 |
Correct |
29 ms |
504 KB |
Output is correct |
6 |
Correct |
29 ms |
504 KB |
Output is correct |
7 |
Correct |
29 ms |
504 KB |
Output is correct |
8 |
Correct |
30 ms |
504 KB |
Output is correct |
9 |
Correct |
29 ms |
504 KB |
Output is correct |
10 |
Correct |
29 ms |
504 KB |
Output is correct |
11 |
Correct |
29 ms |
504 KB |
Output is correct |
12 |
Correct |
29 ms |
568 KB |
Output is correct |
13 |
Correct |
29 ms |
536 KB |
Output is correct |
14 |
Correct |
29 ms |
504 KB |
Output is correct |
15 |
Correct |
29 ms |
504 KB |
Output is correct |
16 |
Correct |
30 ms |
504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
552 KB |
Output is correct |
2 |
Correct |
29 ms |
504 KB |
Output is correct |
3 |
Correct |
29 ms |
516 KB |
Output is correct |
4 |
Correct |
29 ms |
504 KB |
Output is correct |
5 |
Correct |
29 ms |
504 KB |
Output is correct |
6 |
Correct |
29 ms |
504 KB |
Output is correct |
7 |
Correct |
29 ms |
504 KB |
Output is correct |
8 |
Correct |
30 ms |
504 KB |
Output is correct |
9 |
Correct |
29 ms |
504 KB |
Output is correct |
10 |
Correct |
29 ms |
504 KB |
Output is correct |
11 |
Correct |
29 ms |
504 KB |
Output is correct |
12 |
Correct |
29 ms |
568 KB |
Output is correct |
13 |
Correct |
29 ms |
536 KB |
Output is correct |
14 |
Correct |
29 ms |
504 KB |
Output is correct |
15 |
Correct |
29 ms |
504 KB |
Output is correct |
16 |
Correct |
30 ms |
504 KB |
Output is correct |
17 |
Correct |
29 ms |
504 KB |
Output is correct |
18 |
Correct |
29 ms |
504 KB |
Output is correct |
19 |
Correct |
29 ms |
504 KB |
Output is correct |
20 |
Correct |
29 ms |
504 KB |
Output is correct |
21 |
Correct |
29 ms |
504 KB |
Output is correct |
22 |
Correct |
29 ms |
504 KB |
Output is correct |
23 |
Correct |
30 ms |
632 KB |
Output is correct |
24 |
Correct |
30 ms |
512 KB |
Output is correct |
25 |
Correct |
31 ms |
504 KB |
Output is correct |
26 |
Correct |
30 ms |
504 KB |
Output is correct |
27 |
Correct |
29 ms |
504 KB |
Output is correct |
28 |
Correct |
29 ms |
504 KB |
Output is correct |
29 |
Correct |
29 ms |
504 KB |
Output is correct |
30 |
Correct |
29 ms |
508 KB |
Output is correct |
31 |
Correct |
29 ms |
504 KB |
Output is correct |
32 |
Correct |
29 ms |
504 KB |
Output is correct |
33 |
Correct |
29 ms |
504 KB |
Output is correct |
34 |
Correct |
29 ms |
508 KB |
Output is correct |
35 |
Correct |
29 ms |
508 KB |
Output is correct |
36 |
Correct |
29 ms |
508 KB |
Output is correct |
37 |
Correct |
29 ms |
504 KB |
Output is correct |
38 |
Correct |
29 ms |
504 KB |
Output is correct |
39 |
Correct |
29 ms |
504 KB |
Output is correct |
40 |
Correct |
29 ms |
504 KB |
Output is correct |
41 |
Correct |
29 ms |
508 KB |
Output is correct |
42 |
Correct |
30 ms |
504 KB |
Output is correct |
43 |
Correct |
30 ms |
504 KB |
Output is correct |
44 |
Correct |
29 ms |
504 KB |
Output is correct |
45 |
Correct |
29 ms |
504 KB |
Output is correct |
46 |
Correct |
29 ms |
504 KB |
Output is correct |
47 |
Correct |
30 ms |
536 KB |
Output is correct |
48 |
Correct |
31 ms |
760 KB |
Output is correct |
49 |
Correct |
29 ms |
504 KB |
Output is correct |
50 |
Correct |
30 ms |
504 KB |
Output is correct |
51 |
Correct |
29 ms |
504 KB |
Output is correct |
52 |
Correct |
29 ms |
504 KB |
Output is correct |
53 |
Correct |
29 ms |
504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
552 KB |
Output is correct |
2 |
Correct |
29 ms |
504 KB |
Output is correct |
3 |
Correct |
29 ms |
516 KB |
Output is correct |
4 |
Correct |
29 ms |
504 KB |
Output is correct |
5 |
Correct |
29 ms |
504 KB |
Output is correct |
6 |
Correct |
29 ms |
504 KB |
Output is correct |
7 |
Correct |
29 ms |
504 KB |
Output is correct |
8 |
Correct |
30 ms |
504 KB |
Output is correct |
9 |
Correct |
29 ms |
504 KB |
Output is correct |
10 |
Correct |
29 ms |
504 KB |
Output is correct |
11 |
Correct |
29 ms |
504 KB |
Output is correct |
12 |
Correct |
29 ms |
568 KB |
Output is correct |
13 |
Correct |
29 ms |
536 KB |
Output is correct |
14 |
Correct |
29 ms |
504 KB |
Output is correct |
15 |
Correct |
29 ms |
504 KB |
Output is correct |
16 |
Correct |
30 ms |
504 KB |
Output is correct |
17 |
Correct |
29 ms |
504 KB |
Output is correct |
18 |
Correct |
29 ms |
504 KB |
Output is correct |
19 |
Correct |
29 ms |
504 KB |
Output is correct |
20 |
Correct |
29 ms |
504 KB |
Output is correct |
21 |
Correct |
29 ms |
504 KB |
Output is correct |
22 |
Correct |
29 ms |
504 KB |
Output is correct |
23 |
Correct |
30 ms |
632 KB |
Output is correct |
24 |
Correct |
30 ms |
512 KB |
Output is correct |
25 |
Correct |
31 ms |
504 KB |
Output is correct |
26 |
Correct |
30 ms |
504 KB |
Output is correct |
27 |
Correct |
29 ms |
504 KB |
Output is correct |
28 |
Correct |
29 ms |
504 KB |
Output is correct |
29 |
Correct |
29 ms |
504 KB |
Output is correct |
30 |
Correct |
29 ms |
508 KB |
Output is correct |
31 |
Correct |
29 ms |
504 KB |
Output is correct |
32 |
Correct |
29 ms |
504 KB |
Output is correct |
33 |
Correct |
29 ms |
504 KB |
Output is correct |
34 |
Correct |
29 ms |
508 KB |
Output is correct |
35 |
Correct |
29 ms |
508 KB |
Output is correct |
36 |
Correct |
29 ms |
508 KB |
Output is correct |
37 |
Correct |
29 ms |
504 KB |
Output is correct |
38 |
Correct |
29 ms |
504 KB |
Output is correct |
39 |
Correct |
29 ms |
504 KB |
Output is correct |
40 |
Correct |
29 ms |
504 KB |
Output is correct |
41 |
Correct |
29 ms |
508 KB |
Output is correct |
42 |
Correct |
30 ms |
504 KB |
Output is correct |
43 |
Correct |
30 ms |
504 KB |
Output is correct |
44 |
Correct |
29 ms |
504 KB |
Output is correct |
45 |
Correct |
29 ms |
504 KB |
Output is correct |
46 |
Correct |
29 ms |
504 KB |
Output is correct |
47 |
Correct |
30 ms |
536 KB |
Output is correct |
48 |
Correct |
31 ms |
760 KB |
Output is correct |
49 |
Correct |
29 ms |
504 KB |
Output is correct |
50 |
Correct |
30 ms |
504 KB |
Output is correct |
51 |
Correct |
29 ms |
504 KB |
Output is correct |
52 |
Correct |
29 ms |
504 KB |
Output is correct |
53 |
Correct |
29 ms |
504 KB |
Output is correct |
54 |
Correct |
29 ms |
504 KB |
Output is correct |
55 |
Correct |
36 ms |
9332 KB |
Output is correct |
56 |
Correct |
30 ms |
504 KB |
Output is correct |
57 |
Correct |
35 ms |
6392 KB |
Output is correct |
58 |
Correct |
60 ms |
4344 KB |
Output is correct |
59 |
Correct |
284 ms |
18064 KB |
Output is correct |
60 |
Correct |
283 ms |
18040 KB |
Output is correct |
61 |
Correct |
284 ms |
18160 KB |
Output is correct |
62 |
Correct |
29 ms |
376 KB |
Output is correct |
63 |
Correct |
276 ms |
17768 KB |
Output is correct |
64 |
Correct |
222 ms |
18040 KB |
Output is correct |
65 |
Correct |
224 ms |
18064 KB |
Output is correct |
66 |
Correct |
225 ms |
17992 KB |
Output is correct |
67 |
Correct |
260 ms |
18040 KB |
Output is correct |
68 |
Correct |
228 ms |
18076 KB |
Output is correct |
69 |
Correct |
231 ms |
18168 KB |
Output is correct |
70 |
Correct |
51 ms |
4404 KB |
Output is correct |
71 |
Correct |
51 ms |
4344 KB |
Output is correct |
72 |
Correct |
50 ms |
4472 KB |
Output is correct |
73 |
Correct |
51 ms |
4472 KB |
Output is correct |
74 |
Correct |
51 ms |
4348 KB |
Output is correct |
75 |
Correct |
50 ms |
4344 KB |
Output is correct |
76 |
Correct |
53 ms |
4508 KB |
Output is correct |
77 |
Correct |
51 ms |
4344 KB |
Output is correct |
78 |
Correct |
52 ms |
4416 KB |
Output is correct |
79 |
Correct |
52 ms |
4344 KB |
Output is correct |
80 |
Correct |
50 ms |
4344 KB |
Output is correct |
81 |
Correct |
50 ms |
4344 KB |
Output is correct |
82 |
Correct |
51 ms |
4472 KB |
Output is correct |
83 |
Correct |
51 ms |
4344 KB |
Output is correct |
84 |
Correct |
51 ms |
4472 KB |
Output is correct |
85 |
Correct |
50 ms |
4344 KB |
Output is correct |
86 |
Correct |
50 ms |
4344 KB |
Output is correct |
87 |
Correct |
50 ms |
4344 KB |
Output is correct |
88 |
Correct |
53 ms |
4344 KB |
Output is correct |
89 |
Correct |
50 ms |
4472 KB |
Output is correct |
90 |
Correct |
50 ms |
4440 KB |
Output is correct |