Submission #222880

#TimeUsernameProblemLanguageResultExecution timeMemory
222880AutoratchDango Maker (JOI18_dango_maker)C++14
13 / 100
5 ms512 KiB
#include <bits/stdc++.h> using namespace std; const int N = 3001; int m,n; char c[N][N]; int v[N][N],h[N][N],vv[N][N],hh[N][N],dp[N][N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> m >> n; for(int i = 1;i <= m;i++) for(int j = 1;j <= n;j++) cin >> c[i][j]; for(int i = 1;i <= m;i++) for(int j = 1;j <= n;j++) { if(i>2 and c[i-2][j]=='R' and c[i-1][j]=='G' and c[i][j]=='W') v[i][j] = 1; if(j>2 and c[i][j-2]=='R' and c[i][j-1]=='G' and c[i][j]=='W') h[i][j] = 1; vv[i][j] = v[i][j]+vv[i-1][j]; v[i][j]+=v[i][j-1]; hh[i][j] = h[i][j]+hh[i][j-1]; h[i][j]+=h[i-1][j]; int ver = v[i][j],hor = h[i][j]; if(i>=3) ver+=dp[i-3][j]; if(j>=3) hor+=dp[i][j-3]; ver = max(ver,vv[i][j]+dp[i][j-1]); hor = max(hor,hh[i][j]+dp[i-1][j]); dp[i][j] = max(ver,hor); dp[i][j] = max(dp[i][j],max(dp[i-1][j],dp[i][j-1])); } cout << dp[m][n]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...