제출 #860245

#제출 시각아이디문제언어결과실행 시간메모리
860245StefanSebezDango Maker (JOI18_dango_maker)C++14
100 / 100
353 ms80676 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int n,m;cin>>n>>m; int a[n+10][m+10]; memset(a,-1,sizeof(a)); for(int i=1;i<=n;i++) { string s;cin>>s; for(int j=0;j<m;j++) { if(s[j]=='R') a[i][j+1]=0; if(s[j]=='G') a[i][j+1]=1; if(s[j]=='W') a[i][j+1]=2; } } int res=0; for(int d=1;d<=n+m;d++) { int i=1,j=d-1,ct=1,dp[n+m+10][5]; memset(dp,0,sizeof(dp)); while(i<=n && j>=1) { if(j>m) { i++; j--; continue; } dp[ct][0]=max(dp[ct-1][0],max(dp[ct-1][1],dp[ct-1][2])); if(a[i][j-1]==0 && a[i][j]==1 && a[i][j+1]==2) dp[ct][1]=max(dp[ct-1][0],dp[ct-1][1])+1; if(a[i-1][j]==0 && a[i][j]==1 && a[i+1][j]==2) dp[ct][2]=max(dp[ct-1][0],dp[ct-1][2])+1; i++; j--; ct++; } ct--; res+=max(dp[ct][0],max(dp[ct][1],dp[ct][2])); } cout<<res<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...