이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |