Submission #1289613

#TimeUsernameProblemLanguageResultExecution timeMemory
1289613omer_faruk_tuzunDango Maker (JOI18_dango_maker)C++20
0 / 100
0 ms332 KiB

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,count1,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[i][j]=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 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')
            {
                b[i][j]=' ';
                b[i+1][j]=' ';
                b[i+1][j]=' ';
                
                
                ++count2;
                ++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;
                
                ++j;
                ++j;
                
            }
        }   
        
    }
        
        
    if (count1>count2)    
        
        cout<<count1<<"\n";
    
    else
        cout<<count2<<"\n";
    
    
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...