이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |