Submission #538409

#TimeUsernameProblemLanguageResultExecution timeMemory
538409__VariattoDango Maker (JOI18_dango_maker)C++17
33 / 100
5 ms6600 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define ll long long const int MAX=1e3+10; int n, m, dp[MAX][3][3]; pair<bool, bool>t[MAX][MAX]; char c[MAX][MAX]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin>>n>>m; for(int i=1; i<=n; i++) for(int j=1; j<=m; j++) cin>>c[i][j]; for(int i=1; i<=n; i++){ for(int j=1; j<=m; j++){ t[i][j].fi=(i+2<=n && c[i][j]=='R' && c[i+1][j]=='G' && c[i+2][j]=='W'); t[i][j].se=(j+2<=m && c[i][j]=='R' && c[i][j+1]=='G' && c[i][j+2]=='W'); } } int wyn=0; for(int i=1; i<=n+m-1; i++){ int sx, sy; if(i<=n) sx=i, sy=1; else sx=n, sy=i-n+1; for(int x=sx, y=sy, l=1; x>=1&&y<=m; x--, y++, l++){ for(int i1=0; i1<=2; i1++) for(int i2=0; i2<=2; i2++) dp[l][0][i1]=max(dp[l][0][i1], dp[l-1][i1][i2]); if(t[x][y].fi){ for(int i1=0; i1<2; i1++) for(int i2=0; i2<2; i2++) dp[l][1][i1]=max(dp[l][1][i1], dp[l-1][i1][i2]+1); } if(t[x][y].se){ for(int i1=0; i1<=2; i1++) for(int i2=0; i2<=2; i2++) dp[l][2][i1]=max(dp[l][2][i1], dp[l-1][i1][i2]+1); } if(x==1||y==m){ int maxi=0; for(int i1=0; i1<=2; i1++) for(int i2=0; i2<=2; i2++) maxi=max(maxi, dp[l][i1][i2]); wyn+=maxi; } } for(int x=sx, y=sy, l=1; x>=1&&y<=m; x--, y++, l++) for(int i1=0; i1<=2; i1++) for(int i2=0; i2<=2; i2++) dp[l][i1][i2]=0; } cout<<wyn<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...