Submission #1115718

#TimeUsernameProblemLanguageResultExecution timeMemory
1115718staszic_ojuzDango Maker (JOI18_dango_maker)C++17
100 / 100
98 ms21540 KiB
#include <bits/stdc++.h>

using namespace std;

const int MAX=3*1e3+7;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    string greed[MAX];
    int n, m;

    cin >> n >> m;

    for (int i=1; i<=n; i++){
        cin >> greed[i];
        greed[i] += "###";
    }

    for (int i=0; i<=m+2; i++){
        greed[0] += "#";
        greed[n+1] += "#";
    }

    int wyn=0;

    for (int i=1; i<=n; i++){
        for (int j=0; j<m; j++){
            if (greed[i][j] == 'R'){
                if ((greed[i][j+1] == 'G') and (greed[i][j+2] == 'W')){
                    wyn++;
                    if ((greed[i-1][j+1] == 'R') and (greed[i+1][j+1] == 'W')){
                        greed[i-1][j+1] = '#';
                        greed[i][j+1] = '#';
                        greed[i][j+2] = '#';
                    }
                    else{
                        greed[i][j] = '#';
                        greed[i][j+1] = '#';
                        greed[i][j+2] = '#';
                    }
                }
            }
            else if (greed[i][j] == 'G'){
                if ((greed[i-1][j] == 'R') and (greed[i+1][j] == 'W')){
                    wyn++;
                    if ((greed[i][j-1] == 'R') and (greed[i][j+1] == 'W')){
                        greed[i][j] = '#';
                        greed[i][j+1] = '#';
                        greed[i-1][j] = '#';
                    }
                    else{
                        greed[i-1][j] = '#';
                        greed[i][j] = '#';
                        greed[i+1][j] = '#';
                    }
                }
            }
        }
    }

    cout << wyn << "\n";

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...