#include<bits/stdc++.h>
using namespace std;
const int MX = 3005;
int dango[MX][MX];
char a[MX][MX];
int dp[MX];
int n, m;
void PlayGround() {
cin>>n>>m;
for(int i=1; i<=n; ++i) {
for(int j=1; j<=m; ++j) {
cin>>a[i][j];
}
}
for(int i=1; i<=n; ++i) {
for(int j=1; j<=m; ++j) {
if(i+2<=n && a[i][j]=='R' && a[i+1][j]=='G' && a[i+2][j]=='W') {
dango[i][j] |= 1;
}
if(j+2<=m && a[i][j]=='R' && a[i][j+1]=='G' && a[i][j+2]=='W') {
dango[i][j] |= 2;
}
}
}
int ans = 0;
for(int S=2; S<=n+m; ++S) {
memset(dp, 0, sizeof dp);
for(int i=n; i>0; --i) if(S-i>=1 && S-i<=m) {
if(dango[i][S-i]&1) {
dp[i] = 1+dp[i+3];
if(S-i-1>0 && (dango[i+1][S-i-1]&1)) ++dp[i];
if(S-i-2>0 && (dango[i+2][S-i-2]&1)) ++dp[i];
}
if(dango[i][S-i]&2) {
dp[i] = max(dp[i], 1+dp[i+1]);
}
dp[i] = max(dp[i], dp[i+1]);
}
ans += *max_element(dp, dp+MX);
}
cout<<ans<<'\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
PlayGround();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |