Submission #1206232

#TimeUsernameProblemLanguageResultExecution timeMemory
1206232VMaksimoski008Dango Maker (JOI18_dango_maker)C++20
0 / 100
0 ms328 KiB
#include <bits/stdc++.h> using namespace std; const int N = 3005; char a[N][N]; int R[N][N], D[N][N], dp[2*N][3]; int main() { int n, m, ans=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=1; i<=n; i++) { for(int j=1; j<=m; j++) { R[i][j] = (j > 1 && a[i][j] == 'G' && a[i][j-1] == 'R' && a[i][j+1] == 'W'); D[i][j] = (i > 1 && a[i][j] == 'G' && a[i-1][j] == 'R' && a[i+1][j] == 'W'); } } for(int i=2; i<=n+m; i++) { for(int j=max(1, i-m); j<min(i, n+1); j++) { int ndp[3] = { 0, 0, 0 }; ndp[0] = max({ dp[i][0], dp[i][1], dp[i][2] }); ndp[1] = D[j][i-j] + max({ dp[i][0], dp[i][2] }); ndp[2] = R[j][i-j] + max({ dp[i][0], dp[i][1] }); for(int k=0; k<3; k++) dp[i][k] = ndp[k]; } ans += max({ dp[i][0], dp[i][1], dp[i][2] }); } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...