Submission #893770

#TimeUsernameProblemLanguageResultExecution timeMemory
893770AiperiiiDango Maker (JOI18_dango_maker)C++14
100 / 100
276 ms102012 KiB
#include <bits/stdc++.h> #define int long long #define all(x) x.begin(),x.end() #define ff first #define ss second #define pb push_back using namespace std; char a[3005][3005]; vector <int> ind[6005]; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n,m; cin>>n>>m; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ cin>>a[i][j]; ind[i+j].pb(i); } } int ans=0; for(int i=0;i<n+m-1;i++){ int dp[ind[i].size()+1][3]; dp[ind[i].size()][0]=0; dp[ind[i].size()][1]=0; dp[ind[i].size()][2]=0; for(int j=ind[i].size()-1;j>=0;j--){ int x=ind[i][j],y=i-ind[i][j]; dp[j][0]=0;dp[j][1]=0;dp[j][2]=0; dp[j][0]=max({dp[j+1][0],dp[j+1][1],dp[j+1][2]}); if(y+1<m && y-1>=0 && a[x][y]=='G' && a[x][y+1]=='W' && a[x][y-1]=='R'){ dp[j][1]=max(dp[j+1][0],dp[j+1][1])+1; } if(x+1<n && x-1>=0 && a[x][y]=='G' && a[x+1][y]=='W' && a[x-1][y]=='R'){ dp[j][2]=max(dp[j+1][0],dp[j+1][2])+1; } } ans+=max({dp[0][0],dp[0][1],dp[0][2]}); } cout<<ans<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...