#include <bits/stdc++.h>
using namespace std;
const int N = 305;
int n, m, d[N][N][4], r;
char a[N][N];
int v(int x, int y, int d){
return
a[x][y] == 'R' &&
a[x + d][y + !d] == 'G' &&
a[x + 2 * d][y + 2 * !d] == 'W';
}
int main(){
cin >> n >> m;
for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) cin >> a[i][j];
for(int t = 2; t <= n + m; t++){
int cm = 0;
for(int i = t - 1, j; i >= 1; i--){
j = t - i;
if(j < 1 || j > m || i < 1 || i > n) continue;
int *c = d[i][j], *p = d[i + 1][j - 1];
c[0] = max(p[0] + v(i, j, 1), p[1]);
c[1] = max(p[2], p[3]);
if(v(i, j, 0)){
c[2] = max(p[0], p[1]) + 1;
c[3] = max(p[2], p[3]) + 1;
}
cm = max(cm, *max_element(c, c + 4));
}
r += cm;
}
cout << r;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
4 ms |
488 KB |
Output is correct |
3 |
Correct |
2 ms |
488 KB |
Output is correct |
4 |
Correct |
3 ms |
504 KB |
Output is correct |
5 |
Correct |
2 ms |
512 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
3 ms |
568 KB |
Output is correct |
8 |
Correct |
4 ms |
572 KB |
Output is correct |
9 |
Correct |
3 ms |
804 KB |
Output is correct |
10 |
Correct |
3 ms |
816 KB |
Output is correct |
11 |
Correct |
3 ms |
816 KB |
Output is correct |
12 |
Correct |
2 ms |
816 KB |
Output is correct |
13 |
Correct |
3 ms |
816 KB |
Output is correct |
14 |
Correct |
3 ms |
816 KB |
Output is correct |
15 |
Correct |
4 ms |
816 KB |
Output is correct |
16 |
Correct |
3 ms |
816 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
4 ms |
488 KB |
Output is correct |
3 |
Correct |
2 ms |
488 KB |
Output is correct |
4 |
Correct |
3 ms |
504 KB |
Output is correct |
5 |
Correct |
2 ms |
512 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
3 ms |
568 KB |
Output is correct |
8 |
Correct |
4 ms |
572 KB |
Output is correct |
9 |
Correct |
3 ms |
804 KB |
Output is correct |
10 |
Correct |
3 ms |
816 KB |
Output is correct |
11 |
Correct |
3 ms |
816 KB |
Output is correct |
12 |
Correct |
2 ms |
816 KB |
Output is correct |
13 |
Correct |
3 ms |
816 KB |
Output is correct |
14 |
Correct |
3 ms |
816 KB |
Output is correct |
15 |
Correct |
4 ms |
816 KB |
Output is correct |
16 |
Correct |
3 ms |
816 KB |
Output is correct |
17 |
Correct |
3 ms |
816 KB |
Output is correct |
18 |
Correct |
4 ms |
816 KB |
Output is correct |
19 |
Correct |
3 ms |
816 KB |
Output is correct |
20 |
Correct |
3 ms |
816 KB |
Output is correct |
21 |
Correct |
3 ms |
816 KB |
Output is correct |
22 |
Correct |
3 ms |
816 KB |
Output is correct |
23 |
Correct |
3 ms |
816 KB |
Output is correct |
24 |
Correct |
3 ms |
816 KB |
Output is correct |
25 |
Correct |
3 ms |
888 KB |
Output is correct |
26 |
Correct |
3 ms |
888 KB |
Output is correct |
27 |
Correct |
3 ms |
888 KB |
Output is correct |
28 |
Correct |
3 ms |
888 KB |
Output is correct |
29 |
Correct |
3 ms |
888 KB |
Output is correct |
30 |
Correct |
3 ms |
888 KB |
Output is correct |
31 |
Correct |
3 ms |
888 KB |
Output is correct |
32 |
Correct |
3 ms |
888 KB |
Output is correct |
33 |
Correct |
3 ms |
888 KB |
Output is correct |
34 |
Correct |
3 ms |
888 KB |
Output is correct |
35 |
Correct |
4 ms |
888 KB |
Output is correct |
36 |
Correct |
2 ms |
888 KB |
Output is correct |
37 |
Correct |
3 ms |
888 KB |
Output is correct |
38 |
Correct |
3 ms |
888 KB |
Output is correct |
39 |
Correct |
3 ms |
888 KB |
Output is correct |
40 |
Correct |
4 ms |
888 KB |
Output is correct |
41 |
Correct |
3 ms |
888 KB |
Output is correct |
42 |
Correct |
4 ms |
888 KB |
Output is correct |
43 |
Correct |
3 ms |
888 KB |
Output is correct |
44 |
Correct |
3 ms |
892 KB |
Output is correct |
45 |
Correct |
2 ms |
896 KB |
Output is correct |
46 |
Correct |
3 ms |
900 KB |
Output is correct |
47 |
Correct |
3 ms |
900 KB |
Output is correct |
48 |
Correct |
4 ms |
932 KB |
Output is correct |
49 |
Correct |
3 ms |
1012 KB |
Output is correct |
50 |
Correct |
2 ms |
1016 KB |
Output is correct |
51 |
Correct |
3 ms |
1016 KB |
Output is correct |
52 |
Correct |
3 ms |
1016 KB |
Output is correct |
53 |
Correct |
2 ms |
1016 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
4 ms |
488 KB |
Output is correct |
3 |
Correct |
2 ms |
488 KB |
Output is correct |
4 |
Correct |
3 ms |
504 KB |
Output is correct |
5 |
Correct |
2 ms |
512 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
3 ms |
568 KB |
Output is correct |
8 |
Correct |
4 ms |
572 KB |
Output is correct |
9 |
Correct |
3 ms |
804 KB |
Output is correct |
10 |
Correct |
3 ms |
816 KB |
Output is correct |
11 |
Correct |
3 ms |
816 KB |
Output is correct |
12 |
Correct |
2 ms |
816 KB |
Output is correct |
13 |
Correct |
3 ms |
816 KB |
Output is correct |
14 |
Correct |
3 ms |
816 KB |
Output is correct |
15 |
Correct |
4 ms |
816 KB |
Output is correct |
16 |
Correct |
3 ms |
816 KB |
Output is correct |
17 |
Correct |
3 ms |
816 KB |
Output is correct |
18 |
Correct |
4 ms |
816 KB |
Output is correct |
19 |
Correct |
3 ms |
816 KB |
Output is correct |
20 |
Correct |
3 ms |
816 KB |
Output is correct |
21 |
Correct |
3 ms |
816 KB |
Output is correct |
22 |
Correct |
3 ms |
816 KB |
Output is correct |
23 |
Correct |
3 ms |
816 KB |
Output is correct |
24 |
Correct |
3 ms |
816 KB |
Output is correct |
25 |
Correct |
3 ms |
888 KB |
Output is correct |
26 |
Correct |
3 ms |
888 KB |
Output is correct |
27 |
Correct |
3 ms |
888 KB |
Output is correct |
28 |
Correct |
3 ms |
888 KB |
Output is correct |
29 |
Correct |
3 ms |
888 KB |
Output is correct |
30 |
Correct |
3 ms |
888 KB |
Output is correct |
31 |
Correct |
3 ms |
888 KB |
Output is correct |
32 |
Correct |
3 ms |
888 KB |
Output is correct |
33 |
Correct |
3 ms |
888 KB |
Output is correct |
34 |
Correct |
3 ms |
888 KB |
Output is correct |
35 |
Correct |
4 ms |
888 KB |
Output is correct |
36 |
Correct |
2 ms |
888 KB |
Output is correct |
37 |
Correct |
3 ms |
888 KB |
Output is correct |
38 |
Correct |
3 ms |
888 KB |
Output is correct |
39 |
Correct |
3 ms |
888 KB |
Output is correct |
40 |
Correct |
4 ms |
888 KB |
Output is correct |
41 |
Correct |
3 ms |
888 KB |
Output is correct |
42 |
Correct |
4 ms |
888 KB |
Output is correct |
43 |
Correct |
3 ms |
888 KB |
Output is correct |
44 |
Correct |
3 ms |
892 KB |
Output is correct |
45 |
Correct |
2 ms |
896 KB |
Output is correct |
46 |
Correct |
3 ms |
900 KB |
Output is correct |
47 |
Correct |
3 ms |
900 KB |
Output is correct |
48 |
Correct |
4 ms |
932 KB |
Output is correct |
49 |
Correct |
3 ms |
1012 KB |
Output is correct |
50 |
Correct |
2 ms |
1016 KB |
Output is correct |
51 |
Correct |
3 ms |
1016 KB |
Output is correct |
52 |
Correct |
3 ms |
1016 KB |
Output is correct |
53 |
Correct |
2 ms |
1016 KB |
Output is correct |
54 |
Incorrect |
8 ms |
1016 KB |
Output isn't correct |
55 |
Halted |
0 ms |
0 KB |
- |