이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
#ifdef Nero
#include "Deb.h"
#else
#define deb(...)
#endif
const int N = 3003;
char c[N][N];
int used[N][N];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
cin >> c[i][j];
}
}
int tmp = 0;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m - 2; ++j) {
if (c[i][j] == 'R' && c[i][j + 1] == 'G' && c[i][j + 2] == 'W') {
tmp++;
used[i][j] = used[i][j + 1] = used[i][j + 2] = true;
}
}
}
for (int i = 0; i < n - 2; ++i) {
for (int j = 0; j < m; ++j) {
if (c[i][j] == 'R' && c[i + 1][j] == 'G' && c[i + 2][j] == 'W') {
if (!used[i][j] && !used[i + 1][j] && !used[i + 2][j]) {
tmp++;
used[i][j] = used[i + 1][j] = used[i + 2][j] = true;
}
}
}
}
int ans = tmp;
tmp = 0;
memset(used, 0, sizeof used);
for (int i = 0; i < n - 2; ++i) {
for (int j = 0; j < m; ++j) {
if (c[i][j] == 'R' && c[i + 1][j] == 'G' && c[i + 2][j] == 'W') {
tmp++;
used[i][j] = used[i + 1][j] = used[i + 2][j] = true;
}
}
}
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m - 2; ++j) {
if (c[i][j] == 'R' && c[i][j + 1] == 'G' && c[i][j + 2] == 'W') {
if (!used[i][j] && !used[i][j + 1] && !used[i][j + 2]) {
tmp++;
used[i][j] = used[i][j + 1] = used[i][j + 2] = true;
}
}
}
}
ans = max(ans, tmp);
cout << ans << '\n';
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... |