#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
char all[3005][3005];
bool have[3005][3005][5]={0};
int DP[3005][3005][5]={0};
int ans=0,a,b,N,M;
int F(int x,int y,int z)
{
if(x>=N||y<0) return 0;
if(have[x][y][z]) return DP[x][y][z];
have[x][y][z]=1;
DP[x][y][z]=F(x+1,y-1,min(z+1,3));
if(y+2<M&&z==3&&all[x][y]=='R'&&all[x][y+1]=='G'&&all[x][y+2]=='W') DP[x][y][z]=max(DP[x][y][z],F(x+1,y-1,min(z+1,3))+1);
if(x+2<N&&all[x][y]=='R'&&all[x+1][y]=='G'&&all[x+2][y]=='W') DP[x][y][z]=max(DP[x][y][z],F(x+1,y-1,1)+1);
return DP[x][y][z];
}
int main()
{
int i,j;
scanf("%d %d",&N,&M);
for(i=0;i<N;i++) scanf("%s",all[i]);
for(i=0;i<M;i++) ans+=F(0,i,3);
for(i=1;i<N;i++) ans+=F(i,M-1,3);
printf("%d\n",ans);
return 0;
}
Compilation message
dango_maker.cpp: In function 'int main()':
dango_maker.cpp:29:11: warning: unused variable 'j' [-Wunused-variable]
29 | int i,j;
| ^
dango_maker.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
30 | scanf("%d %d",&N,&M);
| ~~~~~^~~~~~~~~~~~~~~
dango_maker.cpp:31:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
31 | for(i=0;i<N;i++) scanf("%s",all[i]);
| ~~~~~^~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
512 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
512 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
492 KB |
Output is correct |
21 |
Correct |
1 ms |
492 KB |
Output is correct |
22 |
Correct |
1 ms |
492 KB |
Output is correct |
23 |
Correct |
1 ms |
492 KB |
Output is correct |
24 |
Correct |
1 ms |
492 KB |
Output is correct |
25 |
Correct |
1 ms |
492 KB |
Output is correct |
26 |
Correct |
1 ms |
364 KB |
Output is correct |
27 |
Correct |
1 ms |
492 KB |
Output is correct |
28 |
Correct |
1 ms |
492 KB |
Output is correct |
29 |
Correct |
1 ms |
492 KB |
Output is correct |
30 |
Correct |
1 ms |
492 KB |
Output is correct |
31 |
Correct |
1 ms |
492 KB |
Output is correct |
32 |
Correct |
1 ms |
492 KB |
Output is correct |
33 |
Correct |
1 ms |
492 KB |
Output is correct |
34 |
Correct |
1 ms |
492 KB |
Output is correct |
35 |
Correct |
1 ms |
492 KB |
Output is correct |
36 |
Correct |
1 ms |
492 KB |
Output is correct |
37 |
Correct |
1 ms |
492 KB |
Output is correct |
38 |
Correct |
1 ms |
492 KB |
Output is correct |
39 |
Correct |
1 ms |
492 KB |
Output is correct |
40 |
Correct |
1 ms |
492 KB |
Output is correct |
41 |
Correct |
1 ms |
492 KB |
Output is correct |
42 |
Correct |
1 ms |
492 KB |
Output is correct |
43 |
Correct |
1 ms |
492 KB |
Output is correct |
44 |
Correct |
1 ms |
492 KB |
Output is correct |
45 |
Correct |
1 ms |
492 KB |
Output is correct |
46 |
Correct |
1 ms |
492 KB |
Output is correct |
47 |
Correct |
1 ms |
492 KB |
Output is correct |
48 |
Correct |
1 ms |
492 KB |
Output is correct |
49 |
Correct |
1 ms |
492 KB |
Output is correct |
50 |
Correct |
1 ms |
492 KB |
Output is correct |
51 |
Correct |
1 ms |
492 KB |
Output is correct |
52 |
Correct |
1 ms |
492 KB |
Output is correct |
53 |
Correct |
1 ms |
492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
512 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
492 KB |
Output is correct |
21 |
Correct |
1 ms |
492 KB |
Output is correct |
22 |
Correct |
1 ms |
492 KB |
Output is correct |
23 |
Correct |
1 ms |
492 KB |
Output is correct |
24 |
Correct |
1 ms |
492 KB |
Output is correct |
25 |
Correct |
1 ms |
492 KB |
Output is correct |
26 |
Correct |
1 ms |
364 KB |
Output is correct |
27 |
Correct |
1 ms |
492 KB |
Output is correct |
28 |
Correct |
1 ms |
492 KB |
Output is correct |
29 |
Correct |
1 ms |
492 KB |
Output is correct |
30 |
Correct |
1 ms |
492 KB |
Output is correct |
31 |
Correct |
1 ms |
492 KB |
Output is correct |
32 |
Correct |
1 ms |
492 KB |
Output is correct |
33 |
Correct |
1 ms |
492 KB |
Output is correct |
34 |
Correct |
1 ms |
492 KB |
Output is correct |
35 |
Correct |
1 ms |
492 KB |
Output is correct |
36 |
Correct |
1 ms |
492 KB |
Output is correct |
37 |
Correct |
1 ms |
492 KB |
Output is correct |
38 |
Correct |
1 ms |
492 KB |
Output is correct |
39 |
Correct |
1 ms |
492 KB |
Output is correct |
40 |
Correct |
1 ms |
492 KB |
Output is correct |
41 |
Correct |
1 ms |
492 KB |
Output is correct |
42 |
Correct |
1 ms |
492 KB |
Output is correct |
43 |
Correct |
1 ms |
492 KB |
Output is correct |
44 |
Correct |
1 ms |
492 KB |
Output is correct |
45 |
Correct |
1 ms |
492 KB |
Output is correct |
46 |
Correct |
1 ms |
492 KB |
Output is correct |
47 |
Correct |
1 ms |
492 KB |
Output is correct |
48 |
Correct |
1 ms |
492 KB |
Output is correct |
49 |
Correct |
1 ms |
492 KB |
Output is correct |
50 |
Correct |
1 ms |
492 KB |
Output is correct |
51 |
Correct |
1 ms |
492 KB |
Output is correct |
52 |
Correct |
1 ms |
492 KB |
Output is correct |
53 |
Correct |
1 ms |
492 KB |
Output is correct |
54 |
Correct |
1 ms |
364 KB |
Output is correct |
55 |
Correct |
18 ms |
33516 KB |
Output is correct |
56 |
Correct |
1 ms |
748 KB |
Output is correct |
57 |
Correct |
16 ms |
22892 KB |
Output is correct |
58 |
Correct |
76 ms |
35844 KB |
Output is correct |
59 |
Correct |
683 ms |
230044 KB |
Output is correct |
60 |
Correct |
656 ms |
238700 KB |
Output is correct |
61 |
Correct |
667 ms |
238700 KB |
Output is correct |
62 |
Correct |
1 ms |
492 KB |
Output is correct |
63 |
Correct |
657 ms |
238404 KB |
Output is correct |
64 |
Correct |
840 ms |
238800 KB |
Output is correct |
65 |
Correct |
841 ms |
238956 KB |
Output is correct |
66 |
Correct |
865 ms |
238860 KB |
Output is correct |
67 |
Correct |
858 ms |
238956 KB |
Output is correct |
68 |
Correct |
842 ms |
238740 KB |
Output is correct |
69 |
Correct |
846 ms |
238956 KB |
Output is correct |
70 |
Correct |
87 ms |
36844 KB |
Output is correct |
71 |
Correct |
89 ms |
36844 KB |
Output is correct |
72 |
Correct |
95 ms |
37004 KB |
Output is correct |
73 |
Correct |
87 ms |
36972 KB |
Output is correct |
74 |
Correct |
90 ms |
36844 KB |
Output is correct |
75 |
Correct |
91 ms |
36844 KB |
Output is correct |
76 |
Correct |
92 ms |
36972 KB |
Output is correct |
77 |
Correct |
87 ms |
36844 KB |
Output is correct |
78 |
Correct |
87 ms |
36844 KB |
Output is correct |
79 |
Correct |
87 ms |
36844 KB |
Output is correct |
80 |
Correct |
87 ms |
36844 KB |
Output is correct |
81 |
Correct |
88 ms |
36844 KB |
Output is correct |
82 |
Correct |
88 ms |
36892 KB |
Output is correct |
83 |
Correct |
87 ms |
36844 KB |
Output is correct |
84 |
Correct |
88 ms |
36844 KB |
Output is correct |
85 |
Correct |
100 ms |
36844 KB |
Output is correct |
86 |
Correct |
90 ms |
36844 KB |
Output is correct |
87 |
Correct |
89 ms |
36972 KB |
Output is correct |
88 |
Correct |
112 ms |
36844 KB |
Output is correct |
89 |
Correct |
88 ms |
36844 KB |
Output is correct |
90 |
Correct |
93 ms |
36888 KB |
Output is correct |