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>
#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(){
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()][3];
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;
if(j+1<ind[i].size()){
dp[j][0]=max({dp[j+1][0],dp[j+1][1],dp[j+1][2]});
dp[j][1]=max({dp[j+1][0],dp[j+1][1],dp[j+1][2]});
dp[j][2]=max({dp[j+1][0],dp[j+1][1],dp[j+1][2]});
}
if(y+2<m && a[x][y]=='R' && a[x][y+1]=='G' && a[x][y+2]=='W') dp[j][1]++;
if(x+2<n && a[x][y]=='R' && a[x+1][y]=='G' && a[x+2][y]=='W'){
int mx=0;
if(j+2<ind[i].size())mx=max({dp[j+2][0],dp[j+2][1],dp[j+2][2]});
if(j+1<ind[i].size())mx=max({dp[j+1][0],dp[j+1][2]});
dp[j][2]=max(mx+1,dp[j][2]);
}
}
ans+=max({dp[0][0],dp[0][1],dp[0][2]});
}
cout<<ans<<"\n";
}
Compilation message (stderr)
dango_maker.cpp: In function 'int main()':
dango_maker.cpp:30:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
30 | if(j+1<ind[i].size()){
| ~~~^~~~~~~~~~~~~~
dango_maker.cpp:39:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | if(j+2<ind[i].size())mx=max({dp[j+2][0],dp[j+2][1],dp[j+2][2]});
| ~~~^~~~~~~~~~~~~~
dango_maker.cpp:40:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | if(j+1<ind[i].size())mx=max({dp[j+1][0],dp[j+1][2]});
| ~~~^~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |