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 <bits/stdc++.h>
using namespace std;
const int N = 3000;
bool dango[2 * N][N][2];
string grid[N];
int n, m;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
for (int i = 0; i < n; ++i) {
cin >> grid[i];
}
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
dango[i + j][i][0] = i < n - 2 && grid[i][j] == 'R' &&
grid[i + 1][j] == 'G' && grid[i + 2][j] == 'W';
dango[i + j][i][1] = j < m - 2 && grid[i][j] == 'R' &&
grid[i][j + 1] == 'G' && grid[i][j + 2] == 'W';
}
}
int ans = 0;
for (int i = 0; i < n + m; ++i) {
int one = 0, two = 0, three = 0;
for (int j = 0; j < n; ++j) {
three = max(three + dango[i][j][1], two);
two = one, one = one + dango[i][j][0];
one = max({one, two, three});
two = max(two, three);
}
ans += max({one, two, three});
}
cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |