// File dangomaker.cpp created on 02.10.2025 at 19:39:09
#include <bits/stdc++.h>
using i64 = long long;
#ifdef DEBUG
#include "/home/ahmetalp/Desktop/Workplace/debug.h"
#else
#define debug(...) void(23)
#endif
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int N, M;
std::cin >> N >> M;
std::vector<std::string> A(N);
for (int i = 0; i < N; ++i) {
std::cin >> A[i];
}
int ans = 0;
std::vector<std::vector<int>> vis(N, std::vector<int>(M));
for (int s = 0; s < N + M; ++s) {
for (int i = 0; i < N; ++i) {
int j = s - i;
if (i < 0 || j < 0 || j >= M) {
continue;
}
if (j + 2 < M) {
if (A[i][j] == 'R' && A[i][j + 1] == 'G' && A[i][j + 2] == 'W'
&& !vis[i][j] && !vis[i][j + 1] && !vis[i][j + 2]) {
vis[i][j] = vis[i][j + 1] = vis[i][j + 2] = true;
ans++;
}
}
if (i + 2 < N) {
if (A[i][j] == 'R' && A[i + 1][j] == 'G' && A[i + 2][j] == 'W'
&& !vis[i][j] && !vis[i + 1][j] && !vis[i + 2][j]) {
vis[i][j] = vis[i + 1][j] = vis[i + 2][j] = true;
ans++;
}
}
}
}
#ifdef DEBUG
for (int i = 0; i < N; ++i) {
debug(vis[i]);
}
#endif
std::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... |