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>
#define fi first
#define se second
#define mp make_pair
using namespace std;
const int N = 3e3 + 5;
char a[N][N];
int n,m;
bool vis[N][N];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
cin >> a[i][j];
int ans = 0;
for (int d = 1; d <= max(n, m); d++) {
if (d <= n) {
for (int j = 1; j <= m; j++) {
if (!(vis[d][j] | vis[d][j + 1] | vis[d][j + 2])
&& a[d][j] == 'R' && a[d][j + 1] == 'G' && a[d][j + 2] == 'W') {
ans++;
vis[d][j] = vis[d][j + 1] = vis[d][j + 2] = true;
}
}
}
if (d <= m) {
for (int i = 1; i <= n; i++) {
if (!(vis[i][d] | vis[i + 1][d] | vis[i + 2][d])
&& a[i][d] == 'R' && a[i + 1][d] == 'G' && a[i + 2][d] == 'W') {
ans++;
vis[i][d] = vis[i + 1][d] = vis[i + 2][d] = true;
}
}
}
}
cout << ans;
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... |