Submission #770321

#TimeUsernameProblemLanguageResultExecution timeMemory
770321gun_ganDango Maker (JOI18_dango_maker)C++17
33 / 100
18 ms444 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MX = 3005; int N, M; int dp[MX][3]; string c[MX]; int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin >> N >> M; for(int i = 0; i < N; i++) cin >> c[i]; int ans = 0; for(int s = 0; s < N + M - 2; s++) { for(int i = 0; i < MX; i++) for(int k = 0; k < 3; k++) dp[i][k] = 0; for(int i = 0; i <= min(s, N - 1); i++) { // i + j = s int j = s - i; dp[i][0] = (i - 1 < 0 ? 0 : max({dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]})); if(c[i][j] == 'G') { if(j - 1 >= 0 && j + 1 < M && c[i][j - 1] == 'R' && c[i][j + 1] == 'W') { dp[i][1] = (i - 1 < 0 ? 0 : max(dp[i - 1][0], dp[i - 1][1])) + 1; } if(i - 1 >= 0 && i + 1 < N && c[i - 1][j] == 'R' && c[i + 1][j] == 'W') { dp[i][2] = (i - 1 < 0 ? 0 : max(dp[i - 1][0], dp[i - 1][2])) + 1; } } } ans += max({dp[min(s, N - 1)][0], dp[min(s, N - 1)][1], dp[min(s, N - 1)][2]}); } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...