제출 #1265143

#제출 시각아이디문제언어결과실행 시간메모리
1265143happyboyDango Maker (JOI18_dango_maker)C++20
100 / 100
356 ms79816 KiB
#include <bits/stdc++.h>
using namespace std;

const int N = 3005;
int n, m, cnt[2][N][N];
char a[N][N];

int main() {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> a[i][j];
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (a[i][j] == 'G') {
                cnt[0][i][j] = (a[i][j - 1] == 'R' && a[i][j + 1] == 'W');
                cnt[1][i][j] = (a[i - 1][j] == 'R' && a[i + 1][j] == 'W');
                if (cnt[0][i - 1][j + 1] | cnt[1][i - 1][j + 1]) {
                    cnt[0][i][j] &= cnt[0][i - 1][j + 1];
                    cnt[1][i][j] &= cnt[1][i - 1][j + 1];
                }
                ans += (cnt[0][i][j] | cnt[1][i][j]);
            }
        }
    }
    cout << ans << "\n";
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...