제출 #1068382

#제출 시각아이디문제언어결과실행 시간메모리
1068382epicci23Dango Maker (JOI18_dango_maker)C++17
0 / 100
1 ms2396 KiB
#include "bits/stdc++.h" #define all(v) v.begin() , v.end() using namespace std; const int INF = 1e9; const int N = 3005; int dp[N][N][2]; bitset<N> ch[N][2]; void _(){ int n,m,ans=0; cin >> n >> m; for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) ch[i][0][j]=ch[i][1][j]=1; vector<string> v; v.push_back("$$$"); for(int i=0;i<n;i++){ string s;cin >> s; s="$"+s+"$"; v.push_back(s); } for(int i=1;i<=n;i++){ for(int j=m;j>=1;j--){ if(v[i][j]!='R'){ dp[i][j][0]=dp[i][j][1]=-INF; ch[i][0][j]=ch[i][1][j]=0; continue; } bool ok0=0,ok1=0; if(i+2<=n && v[i+1][j]=='G' && v[i+2][j]=='W') ok0=1; if(j+2<=m && v[i][j+1]=='G' && v[i][j+2]=='W') ok1=1; if(!ok0 && !ok1){ dp[i][j][0]=dp[i][j][1]=-INF; ch[i][0][j]=ch[i][1][j]=0; continue; } if(ok0){ dp[i][j][0]=1; if(i-1>=1 && j+1<=m && v[i-1][j+1]=='R'){ dp[i][j][0]=max(dp[i][j][0],max(dp[i-1][j+1][1],dp[i-1][j+1][0])+1); ch[i-1][1][j+1]=ch[i-1][0][j+1]=0; } } else{ ch[i][0][j]=0; dp[i][j][0]=-INF; } if(ok1){ dp[i][j][1]=1; if(i-1>=1 && j+1<=m && v[i-1][j+1]=='R'){ dp[i][j][1]=max(dp[i][j][1],dp[i-1][j+1][1]+1); ch[i-1][1][j+1]=0; } if(i-2>=1 && j+2<=m && v[i-2][j+2]=='R'){ dp[i][j][1]=max(dp[i][j][1],dp[i-2][j+2][1]+1); ch[i-2][1][j+2]=0; } } else{ ch[i][1][j]=0; dp[i][j][1]=-INF; } } } for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ int cur=0; if(ch[i][0][j]) cur=max(cur,dp[i][j][0]); if(ch[i][1][j]) cur=max(cur,dp[i][j][1]); ans+=cur; } } cout << ans << '\n'; } int32_t main(){ cin.tie(0); ios::sync_with_stdio(0); int tc=1;//cin >> tc; while(tc--) _(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...