This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define pb push_back
const int N=6e3+12;
char a[N][N];
int dp[N][3];
signed main(){
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 k=2;k<=n+m;k++){
for(int i=0;i<N;i++){
for(int j=0;j<3;j++)dp[i][j]=0;
}
int j=min(m,k-1),i=k-j;
int p=0;
while(j>=1 and j<=m){
dp[i][0]=max({dp[i-1][0],dp[i-1][1],dp[i-1][2]});
if(a[i][j]=='G' and a[i][j-1]=='R' and a[i][j+1]=='W'){
dp[i][1]=max(dp[i-1][0],dp[i-1][1])+1;
}
if(a[i][j]=='G' and a[i-1][j]=='R' and a[i+1][j]=='W'){
dp[i][2]=max(dp[i-1][0],dp[i-1][2])+1;
}
i++;j--;
}
ans+=max({dp[i-1][0],dp[i-1][1],dp[i-1][2]});
}
cout<<ans;
}
Compilation message (stderr)
dango_maker.cpp: In function 'int main()':
dango_maker.cpp:27:13: warning: unused variable 'p' [-Wunused-variable]
27 | int p=0;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |