This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int countDangoSticks(const vector<string>& grid) {
int rows = grid.size();
int cols = grid[0].size();
int count = 0;
for (int i = 0; i < rows; ++i) {
for (int j = 0; j < cols - 2; ++j) {
if (grid[i][j] == 'R' && grid[i][j + 1] == 'G' && grid[i][j + 2] == 'W') {
count++;
}
}
}
for (int i = 0; i < rows - 2; ++i) {
for (int j = 0; j < cols; ++j) {
if (grid[i][j] == 'R' && grid[i + 1][j] == 'G' && grid[i + 2][j] == 'W') {
count++;
}
}
}
return count;
}
int main() {
int n,m;
cin>>n>>m;
vector<string> grid(n);
for(int i = 0;i<n;i++){
cin>>grid[i];
}
int result = countDangoSticks(grid);
cout << result << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |