Submission #380446

#TimeUsernameProblemLanguageResultExecution timeMemory
380446NintsiChkhaidzeDango Maker (JOI18_dango_maker)C++14
100 / 100
318 ms123884 KiB
#include <bits/stdc++.h> using namespace std; char a[3005][3005]; int dp[3][3005][3005]; int main(){ ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL); int n,m; cin>>n>>m; for (int i=1;i<=n;i++) for (int j=1;j<=m;j++) cin>>a[i][j]; int ans=0; for (int i=1;i<=n;i++){ for (int j=1;j<=m;j++){ dp[0][i][j] = max(dp[0][i - 1][j+1],max(dp[1][i-1][j+1],dp[2][i-1][j+1])); if (a[i][j]=='G') { if (a[i][j - 1] == 'R' && a[i][j + 1] == 'W') dp[1][i][j] = max(dp[1][i - 1][j + 1],dp[0][i - 1][j + 1]) + 1; if (a[i - 1][j] == 'R' && a[i + 1][j] == 'W') dp[2][i][j] = max(dp[2][i - 1][j + 1],dp[0][i - 1][j + 1]) + 1; } if (i == n || j == 1) ans+=max(dp[0][i][j],max(dp[1][i][j],dp[2][i][j])); } } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...