#include <bits/stdc++.h>
using namespace std;
const int mxN = 3001;
int n, m, ans = 0; bool g[mxN][mxN]; string s[mxN];
string c = "RGW";
inline bool okay(int x, int y){
return (x >= 0 && y >= 0 && x < n && y < m && !g[x][y]);
}
int32_t main(){
cin >> n >> m;
for(int i=0; i < n; i++){
cin >> s[i];
}
for(int i=n-1; i >= 0; i--){
for(int j=m-1; j>=0; j--){
string cur = "";
for(int k = 0; k < 3; k++){
if(okay(i+k, j)) cur += s[i+k][j];
}
if(cur == c) g[i][j] = 1;
cur = "";
for(int k = 0; k < 3; k++){
if(okay(i, j + k)) cur += s[i][j + k];
}
if(cur == c) g[i][j] = 1;
}
}
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
ans += g[i][j];
}
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |