#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#pragma ("reroll")
#define skip continue;
#define gold ios_base::sync_with_stdio(false);cin.tie(NULL);
#define xa "\n"
#define int long long
#define all(a) a.begin(), a.end()
#define pb push_back
using namespace std;
const int mod = 1e9 + 7;
const int N = 3e3 + 7;
const int MAX = 1e9;
const int inf = 1e18;
int gcd(int a, int b) { if (b == 0) return a; else if(a == 0) return b; else return gcd(b, a % b); }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
char x[N][N];
void solve() {
int n, m;
cin >> n >> m;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cin >> x[i][j];
}
}
int cnt = 0;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(x[i][j] == 'R'){
if(x[i][j + 1] == 'G' && x[i][j + 2] == 'W'){
x[i][j] = '.';
x[i][j + 1] = '.';
x[i][j + 2] = '.';
cnt++;
}
else if(x[i + 1][j] == 'G' && x[i + 2][j] == 'W'){
if((x[i + 1][j - 1] == 'R' && x[i + 1][j] == 'G' && x[i + 1][j + 1] == 'W') && (x[i + 2][j - 2] == 'R' && x[i + 2][j - 1] == 'G' && x[i + 2][j] == 'W')) skip;
x[i][j] = '.';
x[i + 1][j] = '.';
x[i + 2][j] = '.';
cnt++;
}
}
}
}
cout << cnt;
}
signed main() {
gold;
//freopen("pails.in", "r", stdin);
//freopen("pails.out", "w", stdout);
int t = 1;
int ti = 1;
//cin >> t;
while (t--) {
//cout << "Case " << ti << ": ";
solve();
ti++;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |