제출 #1276515

#제출 시각아이디문제언어결과실행 시간메모리
1276515baotoan655Dango Maker (JOI18_dango_maker)C++20
100 / 100
144 ms80052 KiB
#include <bits/stdc++.h> #define file(name) if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); } using namespace std; const int N = 3005; int dp[2][N][N]; char a[N][N]; int n, m; int main() { ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); // file("A") else file("task"); 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') { dp[0][i][j] = (a[i - 1][j] == 'R' && a[i + 1][j] == 'W'); dp[1][i][j] = (a[i][j - 1] == 'R' && a[i][j + 1] == 'W'); if(dp[0][i - 1][j + 1] | dp[1][i - 1][j + 1]) { dp[0][i][j] &= dp[0][i - 1][j + 1]; dp[1][i][j] &= dp[1][i - 1][j + 1]; } ans += (dp[0][i][j] | dp[1][i][j]); } } cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...