#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sp <<" "<<
int inf = 2e18;
void solve()
{
int n,m;
cin >> n >> m;
char dizi[n][m];
for(int i=0;i<n;i++)for(int j=0;j<m;j++)cin >> dizi[i][j];
int semboller = 0;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
if(j+2 < m && dizi[i][j]=='R' && dizi[i][j+1]=='G' && dizi[i][j+2]=='W')
{
if(dizi[i][j]!='0' && dizi[i][j+1]!='0' && dizi[i][j+2]!='0')
{
semboller++;
dizi[i][j] = dizi[i][j+1] = dizi[i][j+2] = '0';
}
}
if(i+2 < n && dizi[i][j]=='R' && dizi[i+1][j]=='G' && dizi[i+2][j]=='W')
{
if(dizi[i][j]!='0' && dizi[i+1][j]!='0' && dizi[i+2][j]!='0')
{
semboller++;
dizi[i][j] = dizi[i+1][j] = dizi[i+2][j] = '0';
}
}
}
}
cout << semboller;
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
#ifdef faruk
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
int t = 1;
//cin>>t;
while (t--) solve();
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... |