제출 #538380

#제출 시각아이디문제언어결과실행 시간메모리
538380new_accDango Maker (JOI18_dango_maker)C++14
0 / 100
1 ms312 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][3]; 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][2],dp[k-1][0])+ok[a][b][0]; dp[k][1]=max({dp[k-1][2],dp[k-1][1],dp[k-1][0]})+ok[a][b][1]; dp[k][2]=dp[k-1][1]; a--,b++; } return max({dp[k][0],dp[k][1],dp[k][2]}); } 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...