Submission #311737

#TimeUsernameProblemLanguageResultExecution timeMemory
311737vipghn2003Dango Maker (JOI18_dango_maker)C++14
100 / 100
569 ms137336 KiB
#include<bits/stdc++.h> #define pii pair<int,int> #define fi first #define se second #define mp make_pair using namespace std; const int N=3005; int n,m,dp[N][3]; bool can[N][N][3]; char a[N][N]; vector<pii>vec[N*2]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin>>n>>m; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { cin>>a[i][j]; vec[i+j].push_back(mp(i,j)); } } for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { if(a[i-1][j]=='R'&&a[i][j]=='G'&&a[i+1][j]=='W') can[i][j][1]=true; if(a[i][j-1]=='R'&&a[i][j]=='G'&&a[i][j+1]=='W') can[i][j][2]=true; } } int res=0; for(int s=2;s<=n+m;s++) { memset(dp,0,sizeof dp); int sz=vec[s].size(); for(int i=1;i<=sz;i++) { int x=vec[s][i-1].fi; int y=vec[s][i-1].se; dp[i][0]=max({dp[i-1][0],dp[i-1][1],dp[i-1][2]}); for(int j=1;j<=2;j++) if(can[x][y][j]) dp[i][j]=max(dp[i-1][0],dp[i-1][j])+1; } res=res+max({dp[sz][0],dp[sz][1],dp[sz][2]}); } cout<<res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...