Submission #481372

#TimeUsernameProblemLanguageResultExecution timeMemory
481372RainbowbunnyDango Maker (JOI18_dango_maker)C++17
13 / 100
1 ms332 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 3005; int n, m, ans; int dp[MAXN][3]; char a[MAXN][MAXN]; 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 >> a[i][j]; } } for(int i = 2; i <= n + m; i++) { int nw = 0; for(int j = 1; j <= min(n, i); j++) { for(int k = 0; k < 3; k++) { dp[j][k] = 0; } } for(int j = 1; j <= min(n, i); j++) { int posx = j, posy = i - j; if(a[posx][posy] == 'R' and a[posx][posy + 1] == 'G' and a[posx][posy + 2] == 'W') { dp[j][0] = max(dp[j][0], dp[j - 1][0] + 1); } if(a[posx][posy] == 'R' and a[posx + 1][posy] == 'G' and a[posx + 2][posy] == 'W') { dp[j][2] = max(dp[j][2], max({dp[j - 1][0], dp[j - 1][1], dp[j - 1][2]}) + 1); } dp[j][0] = max(dp[j][0], dp[j - 1][1]); dp[j][1] = max(dp[j][1], dp[j - 1][2]); nw = max({nw, dp[j][0], dp[j][1], dp[j][2]}); } ans += nw; } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...