#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m,count1=0,count2=0;
cin>>n>>m;//n satır sayısı m sütun sayısı
char a[n][m], b[n][m];
for(int i=0;i<n;++i)
{
for(int j=0;j<m;++j)
{
cin>>a[i][j];
b[j][i]=a[i][j];
}
}
for(int i=0;i<n;++i)
{
for(int j=0;j<m-2;++j)
{
if (a[i][j]=='R'&&a[i][j+1]=='G'&&a[i][j+2]=='W')
{
++count1;
a[i][j]=' ';
a[i][j+1]=' ';
a[i][j+2]=' ';
++j;
++j;
}
}
}
for(int j=0;j<m;++j)
{
for (int i=0;i<n-2;++i)
{
if(a[i][j]=='R'&&a[i+1][j]=='G'&&a[i+2][j]=='W')
{
++count1;
++i;
++i;
}
}
}
for(int i=0;i<n;++i)
{
for(int j=0;j<m-2;++j)
{
if (b[i][j]=='R'&&b[i][j+1]=='G'&&b[i][j+2]=='W')
{
++count2;
b[i][j]=' ';
b[i][j+1]=' ';
b[i][j+2]=' ';
++j;
++j;
}
}
}
for(int j=0;j<m;++j)
{
for (int i=0;i<n-2;++i)
{
if(b[i][j]=='R'&&b[i+1][j]=='G'&&b[i+2][j]=='W')
{
++count2;
++i;
++i;
}
}
}
if (count1>count2)
cout<<count1<<"\n";
else
cout<<count2<<"\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... |