Submission #538385

#TimeUsernameProblemLanguageResultExecution timeMemory
538385new_accDango Maker (JOI18_dango_maker)C++14
100 / 100
655 ms35340 KiB
#include<bits/stdc++.h> #define fi first #define se second #define pitem item* using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; const int N=3e3+10; bool ok[N][N][2]; char t[N][N]; int dp[N][4]; int n,m; int diag(int a,int b){ int k=0; while(a>0 and b<=m){ k++; dp[k][0]=max(dp[k-1][3],dp[k-1][0])+ok[a][b][0]; dp[k][1]=max({dp[k-1][2],dp[k-1][1],dp[k-1][0],dp[k-1][3]})+ok[a][b][1]; dp[k][2]=dp[k-1][1],dp[k][3]=dp[k-1][2]; a--,b++; } return max({dp[k][0],dp[k][1],dp[k][2],dp[k][3]}); } void solve(){ cin>>n>>m; for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) cin>>t[i][j]; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ if(t[i][j]=='R'){ if(i+2<=n and t[i+1][j]=='G' and t[i+2][j]=='W') ok[i][j][0]=1; if(j+2<=m and t[i][j+1]=='G' and t[i][j+2]=='W') ok[i][j][1]=1; } } } int res=0; for(int i=1;i<=n;i++) res+=diag(i,1); for(int i=2;i<=m;i++) res+=diag(n,i); cout<<res<<"\n"; } int main(){ solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...