#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
const int N = 3005;
int n, m;
int ver[N], hor[N];
char a[N][N];
bool up[N], rt[N];
int solve(int N) {
for (int i = 1; i <= N; ++i) {
ver[i] = ver[i - 1];
hor[i] = hor[i - 1];
if (i > 1) {
hor[i] = max(hor[i], ver[i - 2]);
ver[i] = max(ver[i], hor[i - 2]);
}
ver[i] += up[i] && rt[i + 1];
hor[i] += up[i + 1] && rt[i];
}
return max(ver[N], hor[N]);
}
bool inside(int i, int j, char c) {
return 1 <= i && i <= n && 1 <= j && j <= m && a[i][j] == c;
}
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n >> m;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
cin >> a[i][j];
}
}
int res = 0;
for (int it = 1; it <= n + m + 1; ++it) {
vector<int> cands;
for (int j = 1; j < it; ++j) {
if (inside(it - j, j, 'G')) {
cands.push_back(j);
}
}
reverse(cands.begin(), cands.end());
for (int i = 0; i < cands.size(); ) {
int j = i;
while (j < cands.size() && cands[i] - cands[j] == j - i) {
++j;
}
for (int k = i; k < j; ++k) {
up[k - i + 1] = inside(it - cands[k] - 1, cands[k], 'R');
rt[k - i + 1] = inside(it - cands[k], cands[k] + 1, 'W');
}
up[j - i + 1] = inside(it - cands[j - 1], cands[j - 1] - 1, 'R');
rt[j - i + 1] = inside(it - cands[j - 1] + 1, cands[j - 1], 'W');
res += solve(j - i);
i = j;
}
}
cout << res;
return 0;
}
Compilation message
dango_maker.cpp: In function 'int main()':
dango_maker.cpp:54:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
54 | for (int i = 0; i < cands.size(); ) {
| ~~^~~~~~~~~~~~~~
dango_maker.cpp:56:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
56 | while (j < cands.size() && cands[i] - cands[j] == j - i) {
| ~~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 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 |
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 |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 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 |
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 |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
352 KB |
Output is correct |
20 |
Correct |
0 ms |
352 KB |
Output is correct |
21 |
Correct |
0 ms |
352 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
352 KB |
Output is correct |
25 |
Correct |
0 ms |
468 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
352 KB |
Output is correct |
31 |
Correct |
1 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 |
352 KB |
Output is correct |
35 |
Correct |
0 ms |
460 KB |
Output is correct |
36 |
Correct |
0 ms |
352 KB |
Output is correct |
37 |
Correct |
0 ms |
348 KB |
Output is correct |
38 |
Correct |
1 ms |
344 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 |
348 KB |
Output is correct |
42 |
Correct |
0 ms |
344 KB |
Output is correct |
43 |
Correct |
1 ms |
356 KB |
Output is correct |
44 |
Correct |
0 ms |
348 KB |
Output is correct |
45 |
Correct |
0 ms |
348 KB |
Output is correct |
46 |
Correct |
0 ms |
344 KB |
Output is correct |
47 |
Correct |
1 ms |
352 KB |
Output is correct |
48 |
Correct |
0 ms |
348 KB |
Output is correct |
49 |
Correct |
0 ms |
348 KB |
Output is correct |
50 |
Correct |
1 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 |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 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 |
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 |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
352 KB |
Output is correct |
20 |
Correct |
0 ms |
352 KB |
Output is correct |
21 |
Correct |
0 ms |
352 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
352 KB |
Output is correct |
25 |
Correct |
0 ms |
468 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
352 KB |
Output is correct |
31 |
Correct |
1 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 |
352 KB |
Output is correct |
35 |
Correct |
0 ms |
460 KB |
Output is correct |
36 |
Correct |
0 ms |
352 KB |
Output is correct |
37 |
Correct |
0 ms |
348 KB |
Output is correct |
38 |
Correct |
1 ms |
344 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 |
348 KB |
Output is correct |
42 |
Correct |
0 ms |
344 KB |
Output is correct |
43 |
Correct |
1 ms |
356 KB |
Output is correct |
44 |
Correct |
0 ms |
348 KB |
Output is correct |
45 |
Correct |
0 ms |
348 KB |
Output is correct |
46 |
Correct |
0 ms |
344 KB |
Output is correct |
47 |
Correct |
1 ms |
352 KB |
Output is correct |
48 |
Correct |
0 ms |
348 KB |
Output is correct |
49 |
Correct |
0 ms |
348 KB |
Output is correct |
50 |
Correct |
1 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 |
0 ms |
348 KB |
Output is correct |
54 |
Correct |
4 ms |
344 KB |
Output is correct |
55 |
Correct |
7 ms |
9052 KB |
Output is correct |
56 |
Correct |
4 ms |
348 KB |
Output is correct |
57 |
Correct |
6 ms |
6376 KB |
Output is correct |
58 |
Correct |
25 ms |
4272 KB |
Output is correct |
59 |
Correct |
202 ms |
18208 KB |
Output is correct |
60 |
Correct |
198 ms |
18000 KB |
Output is correct |
61 |
Correct |
201 ms |
17868 KB |
Output is correct |
62 |
Correct |
4 ms |
348 KB |
Output is correct |
63 |
Correct |
214 ms |
17640 KB |
Output is correct |
64 |
Correct |
116 ms |
17928 KB |
Output is correct |
65 |
Correct |
123 ms |
18112 KB |
Output is correct |
66 |
Correct |
124 ms |
18116 KB |
Output is correct |
67 |
Correct |
133 ms |
18004 KB |
Output is correct |
68 |
Correct |
131 ms |
18000 KB |
Output is correct |
69 |
Correct |
133 ms |
18000 KB |
Output is correct |
70 |
Correct |
13 ms |
4188 KB |
Output is correct |
71 |
Correct |
13 ms |
4160 KB |
Output is correct |
72 |
Correct |
13 ms |
4408 KB |
Output is correct |
73 |
Correct |
16 ms |
4184 KB |
Output is correct |
74 |
Correct |
13 ms |
4188 KB |
Output is correct |
75 |
Correct |
16 ms |
4188 KB |
Output is correct |
76 |
Correct |
13 ms |
4348 KB |
Output is correct |
77 |
Correct |
13 ms |
4188 KB |
Output is correct |
78 |
Correct |
13 ms |
4188 KB |
Output is correct |
79 |
Correct |
14 ms |
4412 KB |
Output is correct |
80 |
Correct |
13 ms |
4188 KB |
Output is correct |
81 |
Correct |
13 ms |
4188 KB |
Output is correct |
82 |
Correct |
15 ms |
4420 KB |
Output is correct |
83 |
Correct |
13 ms |
4356 KB |
Output is correct |
84 |
Correct |
14 ms |
4188 KB |
Output is correct |
85 |
Correct |
14 ms |
4188 KB |
Output is correct |
86 |
Correct |
14 ms |
4184 KB |
Output is correct |
87 |
Correct |
14 ms |
4188 KB |
Output is correct |
88 |
Correct |
14 ms |
4416 KB |
Output is correct |
89 |
Correct |
13 ms |
4188 KB |
Output is correct |
90 |
Correct |
13 ms |
4188 KB |
Output is correct |