제출 #557483

#제출 시각아이디문제언어결과실행 시간메모리
557483alextodoranDango Maker (JOI18_dango_maker)C++17
100 / 100
282 ms35680 KiB
/** ____ ____ ____ ____ ____ ||a |||t |||o |||d |||o || ||__|||__|||__|||__|||__|| |/__\|/__\|/__\|/__\|/__\| **/ #include <bits/stdc++.h> using namespace std; typedef long long ll; const int D_MAX = 3000; int N, M; char mat[D_MAX + 2][D_MAX + 2]; bool H[D_MAX + 2][D_MAX + 2]; bool V[D_MAX + 2][D_MAX + 2]; int main () { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> N >> M; for (int i = 1; i <= N; i++) { for (int j = 1; j <= M; j++) { cin >> mat[i][j]; } } for (int i = 1; i <= N; i++) { for (int j = 1; j <= M; j++) { if (mat[i][j] == 'G') { if (1 < j && j < M && mat[i][j - 1] == 'R' && mat[i][j + 1] == 'W') { H[i][j] = true; } if (1 < i && i < N && mat[i - 1][j] == 'R' && mat[i + 1][j] == 'W') { V[i][j] = true; } } } } int answer = 0; for (int s = 1 + 1; s <= N + M; s++) { int i1 = max(1, s - M), i2 = min(N, s - 1); int dp[2][3]; dp[0][0] = dp[0][1] = dp[0][2] = 0; for (int i = i1; i <= i2; i++) { int j = s - i; dp[1][0] = max({dp[0][0], dp[0][1], dp[0][2]}); if (H[i][j] == true) { dp[1][1] = max(dp[0][0], dp[0][1]) + 1; } else { dp[1][1] = 0; } if (V[i][j] == true) { dp[1][2] = max(dp[0][0], dp[0][2]) + 1; } else { dp[1][2] = 0; } swap(dp[0], dp[1]); } answer += max({dp[0][0], dp[0][1], dp[0][2]}); } cout << answer << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...