#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define pb push_back
const int N=6e3+12;
char a[N][N];
int dp[N][3];
signed main(){
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>a[i][j];
}
}
int ans=0;
for(int k=2;k<=n+m;k++){
for(int i=0;i<N;i++){
for(int j=0;j<3;j++)dp[i][j]=0;
}
int j=min(m,k-1),i=k-j;
int p=0;
while(j>=1 and j<=m){
dp[i][0]=max({dp[i-1][0],dp[i-1][1],dp[i-1][2]});
if(a[i][j]=='G' and a[i][j-1]=='R' and a[i][j+1]=='W'){
dp[i][1]=max(dp[i-1][0],dp[i-1][1])+1;
}
if(a[i][j]=='G' and a[i-1][j]=='R' and a[i+1][j]=='W'){
dp[i][2]=max(dp[i-1][0],dp[i-1][2])+1;
}
i++;j--;
}
ans+=max({dp[i-1][0],dp[i-1][1],dp[i-1][2]});
}
cout<<ans;
}
Compilation message
dango_maker.cpp: In function 'int main()':
dango_maker.cpp:27:13: warning: unused variable 'p' [-Wunused-variable]
27 | int p=0;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 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 |
1 ms |
600 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
604 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
604 KB |
Output is correct |
12 |
Correct |
0 ms |
604 KB |
Output is correct |
13 |
Correct |
0 ms |
604 KB |
Output is correct |
14 |
Correct |
0 ms |
604 KB |
Output is correct |
15 |
Correct |
0 ms |
604 KB |
Output is correct |
16 |
Correct |
0 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 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 |
1 ms |
600 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
604 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
604 KB |
Output is correct |
12 |
Correct |
0 ms |
604 KB |
Output is correct |
13 |
Correct |
0 ms |
604 KB |
Output is correct |
14 |
Correct |
0 ms |
604 KB |
Output is correct |
15 |
Correct |
0 ms |
604 KB |
Output is correct |
16 |
Correct |
0 ms |
604 KB |
Output is correct |
17 |
Correct |
1 ms |
600 KB |
Output is correct |
18 |
Correct |
0 ms |
604 KB |
Output is correct |
19 |
Correct |
0 ms |
604 KB |
Output is correct |
20 |
Correct |
0 ms |
444 KB |
Output is correct |
21 |
Correct |
0 ms |
604 KB |
Output is correct |
22 |
Correct |
0 ms |
604 KB |
Output is correct |
23 |
Correct |
0 ms |
604 KB |
Output is correct |
24 |
Correct |
0 ms |
600 KB |
Output is correct |
25 |
Correct |
0 ms |
604 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
604 KB |
Output is correct |
28 |
Correct |
1 ms |
604 KB |
Output is correct |
29 |
Correct |
0 ms |
604 KB |
Output is correct |
30 |
Correct |
0 ms |
604 KB |
Output is correct |
31 |
Correct |
0 ms |
604 KB |
Output is correct |
32 |
Correct |
0 ms |
604 KB |
Output is correct |
33 |
Correct |
1 ms |
604 KB |
Output is correct |
34 |
Correct |
0 ms |
604 KB |
Output is correct |
35 |
Correct |
1 ms |
600 KB |
Output is correct |
36 |
Correct |
1 ms |
604 KB |
Output is correct |
37 |
Correct |
0 ms |
440 KB |
Output is correct |
38 |
Correct |
0 ms |
632 KB |
Output is correct |
39 |
Correct |
1 ms |
604 KB |
Output is correct |
40 |
Correct |
0 ms |
604 KB |
Output is correct |
41 |
Correct |
1 ms |
600 KB |
Output is correct |
42 |
Correct |
1 ms |
600 KB |
Output is correct |
43 |
Correct |
0 ms |
604 KB |
Output is correct |
44 |
Correct |
0 ms |
604 KB |
Output is correct |
45 |
Correct |
1 ms |
604 KB |
Output is correct |
46 |
Correct |
0 ms |
604 KB |
Output is correct |
47 |
Correct |
0 ms |
604 KB |
Output is correct |
48 |
Correct |
0 ms |
604 KB |
Output is correct |
49 |
Correct |
0 ms |
604 KB |
Output is correct |
50 |
Correct |
1 ms |
604 KB |
Output is correct |
51 |
Correct |
0 ms |
604 KB |
Output is correct |
52 |
Correct |
1 ms |
604 KB |
Output is correct |
53 |
Correct |
0 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 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 |
1 ms |
600 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
604 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
604 KB |
Output is correct |
12 |
Correct |
0 ms |
604 KB |
Output is correct |
13 |
Correct |
0 ms |
604 KB |
Output is correct |
14 |
Correct |
0 ms |
604 KB |
Output is correct |
15 |
Correct |
0 ms |
604 KB |
Output is correct |
16 |
Correct |
0 ms |
604 KB |
Output is correct |
17 |
Correct |
1 ms |
600 KB |
Output is correct |
18 |
Correct |
0 ms |
604 KB |
Output is correct |
19 |
Correct |
0 ms |
604 KB |
Output is correct |
20 |
Correct |
0 ms |
444 KB |
Output is correct |
21 |
Correct |
0 ms |
604 KB |
Output is correct |
22 |
Correct |
0 ms |
604 KB |
Output is correct |
23 |
Correct |
0 ms |
604 KB |
Output is correct |
24 |
Correct |
0 ms |
600 KB |
Output is correct |
25 |
Correct |
0 ms |
604 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
604 KB |
Output is correct |
28 |
Correct |
1 ms |
604 KB |
Output is correct |
29 |
Correct |
0 ms |
604 KB |
Output is correct |
30 |
Correct |
0 ms |
604 KB |
Output is correct |
31 |
Correct |
0 ms |
604 KB |
Output is correct |
32 |
Correct |
0 ms |
604 KB |
Output is correct |
33 |
Correct |
1 ms |
604 KB |
Output is correct |
34 |
Correct |
0 ms |
604 KB |
Output is correct |
35 |
Correct |
1 ms |
600 KB |
Output is correct |
36 |
Correct |
1 ms |
604 KB |
Output is correct |
37 |
Correct |
0 ms |
440 KB |
Output is correct |
38 |
Correct |
0 ms |
632 KB |
Output is correct |
39 |
Correct |
1 ms |
604 KB |
Output is correct |
40 |
Correct |
0 ms |
604 KB |
Output is correct |
41 |
Correct |
1 ms |
600 KB |
Output is correct |
42 |
Correct |
1 ms |
600 KB |
Output is correct |
43 |
Correct |
0 ms |
604 KB |
Output is correct |
44 |
Correct |
0 ms |
604 KB |
Output is correct |
45 |
Correct |
1 ms |
604 KB |
Output is correct |
46 |
Correct |
0 ms |
604 KB |
Output is correct |
47 |
Correct |
0 ms |
604 KB |
Output is correct |
48 |
Correct |
0 ms |
604 KB |
Output is correct |
49 |
Correct |
0 ms |
604 KB |
Output is correct |
50 |
Correct |
1 ms |
604 KB |
Output is correct |
51 |
Correct |
0 ms |
604 KB |
Output is correct |
52 |
Correct |
1 ms |
604 KB |
Output is correct |
53 |
Correct |
0 ms |
604 KB |
Output is correct |
54 |
Correct |
25 ms |
604 KB |
Output is correct |
55 |
Correct |
16 ms |
12380 KB |
Output is correct |
56 |
Correct |
20 ms |
628 KB |
Output is correct |
57 |
Correct |
11 ms |
8644 KB |
Output is correct |
58 |
Correct |
44 ms |
6484 KB |
Output is correct |
59 |
Correct |
343 ms |
25172 KB |
Output is correct |
60 |
Correct |
362 ms |
26932 KB |
Output is correct |
61 |
Correct |
379 ms |
26960 KB |
Output is correct |
62 |
Correct |
23 ms |
604 KB |
Output is correct |
63 |
Correct |
349 ms |
26648 KB |
Output is correct |
64 |
Correct |
340 ms |
26960 KB |
Output is correct |
65 |
Correct |
338 ms |
26964 KB |
Output is correct |
66 |
Correct |
320 ms |
26960 KB |
Output is correct |
67 |
Correct |
326 ms |
27036 KB |
Output is correct |
68 |
Correct |
336 ms |
26964 KB |
Output is correct |
69 |
Correct |
333 ms |
27060 KB |
Output is correct |
70 |
Correct |
41 ms |
6484 KB |
Output is correct |
71 |
Correct |
46 ms |
6480 KB |
Output is correct |
72 |
Correct |
44 ms |
6488 KB |
Output is correct |
73 |
Correct |
48 ms |
6484 KB |
Output is correct |
74 |
Correct |
55 ms |
6484 KB |
Output is correct |
75 |
Correct |
48 ms |
6436 KB |
Output is correct |
76 |
Correct |
51 ms |
6484 KB |
Output is correct |
77 |
Correct |
44 ms |
6296 KB |
Output is correct |
78 |
Correct |
49 ms |
6492 KB |
Output is correct |
79 |
Correct |
44 ms |
6480 KB |
Output is correct |
80 |
Correct |
45 ms |
6480 KB |
Output is correct |
81 |
Correct |
42 ms |
6480 KB |
Output is correct |
82 |
Correct |
42 ms |
6540 KB |
Output is correct |
83 |
Correct |
49 ms |
6488 KB |
Output is correct |
84 |
Correct |
42 ms |
6480 KB |
Output is correct |
85 |
Correct |
40 ms |
6296 KB |
Output is correct |
86 |
Correct |
43 ms |
6484 KB |
Output is correct |
87 |
Correct |
40 ms |
6340 KB |
Output is correct |
88 |
Correct |
39 ms |
6480 KB |
Output is correct |
89 |
Correct |
39 ms |
6488 KB |
Output is correct |
90 |
Correct |
41 ms |
6536 KB |
Output is correct |