Submission #893761

#TimeUsernameProblemLanguageResultExecution timeMemory
893761AiperiiiDango Maker (JOI18_dango_maker)C++14
100 / 100
732 ms102528 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; signed main(){ ios_base::sync_with_stdio(); cin.tie(0); int n,m; cin>>n>>m; char a[n][m]; vector <int> ind[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-2;i++){ vector <vector <int> > dp(ind[i].size()+1,vector <int> (3,0)); for(int j=ind[i].size()-1;j>=0;j--){ int x=ind[i][j],y=i-ind[i][j]; 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...