Submission #544887

#TimeUsernameProblemLanguageResultExecution timeMemory
544887pokmui9909Dango Maker (JOI18_dango_maker)C++17
100 / 100
239 ms18172 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; ll N, M; char A[3005][3005]; ll D[6005][3]; int main(){ cin.tie(0) -> sync_with_stdio(false); cin >> N >> M; for(int i = 1; i <= N; i++){ for(int j = 1; j <= M; j++){ cin >> A[i][j]; } } ll ans = 0; for(int k = 1; k <= N + M; k++){ memset(D, 0, sizeof(D)); int t = 0; for(int i = 1; i <= N; i++){ int j = k - i; if(j < 1 || j > M) continue; D[i][0] = max({D[i - 1][0], D[i - 1][1], D[i - 1][2]}); if(A[i][j] == 'G' && A[i - 1][j] == 'R' && A[i + 1][j] == 'W') D[i][1] = max(D[i - 1][0], D[i - 1][1]) + 1; if(A[i][j] == 'G' && A[i][j - 1] == 'R' && A[i][j + 1] == 'W') D[i][2] = max(D[i - 1][0], D[i - 1][2]) + 1; t = i; } ans += max({D[t][0], D[t][1], D[t][2]}); } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...