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>
using namespace std;
using i64 = int64_t;
vector<string> table;
struct Rgw
{
    i64 x;
    i64 y;
    bool dol;
    i64 krz;
};
bool RGW(i64 x, i64 y, bool b)
{
    if (b == false && table[x][y] == 'R' && table[x][y + 1] == 'G' && table[x][y + 2] == 'W')
    {
        return true;
    }
    if (b && table[x][y] == 'R' && table[x + 1][y] == 'G' && table[x + 2][y] == 'W')
    {
        return true;
    }
    return false;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    i64 N, M;
    cin >> N >> M;
    table.resize(N);
    for (i64 i = 0; i < N; i++)
    {
        cin >> table[i];
    }
    i64 wynik = 0;
    for (i64 i = 0; i < N; i++)
    {
        for (i64 k = 0; k < M; k++)
        {
            if (k < M - 2 && RGW(i, k, 0))
            {
                if (i > 0 && i < N - 1 && RGW(i - 1, k + 1, 1))
                {
                    table[i - 1][k + 1] = '#';
                    table[i][k + 1] = '#';
                    table[i][k + 2] = '#';
                    wynik++;
                }
                else
                {
                    wynik++;
                    table[i][k] = '#';
                    table[i][k + 1] = '#';
                    table[i][k + 2] = '#';
                }
            }
            if (table[i][k] == 'G' && i < 0 && i < N - 1 && RGW(i - 1, k, 1))
            {
                wynik++;
                table[i - 1][k] = '#';
                table[i][k] = '#';
                table[i + 1][k] = '#';
            }
         }
    }
    for (i64 i = 0; i < N - 2; i++)
    {
        for (i64 k = 0; k < M; k++)
        {
            //cout << table[i][k];
            if (RGW(i, k, 1))
            {
                wynik++;
            }
        }
        //cout << "\n";
    }
    cout << wynik << "\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... |