제출 #441241

#제출 시각아이디문제언어결과실행 시간메모리
441241ritul_kr_singhDango Maker (JOI18_dango_maker)C++17
100 / 100
923 ms11588 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define sp << ' ' << #define nl << '\n' const int MAXN = 3e3; int n, m, dp[3][3]; string g[MAXN+1]; bool up(int i, int j){ return i > 2 && g[i-2][j] == 'R' && g[i-1][j] == 'G' && g[i][j] == 'W'; } bool left(int i, int j){ return j > 2 && g[i][j-2] == 'R' && g[i][j-1] == 'G' && g[i][j] == 'W'; } signed main(){ cin.tie(0)->sync_with_stdio(0); cin >> n >> m; for(int i=1; i<=n; ++i) cin >> g[i], g[i] = ' ' + g[i]; for(int s=2; s<=n+m; ++s){ int i = max(1LL, s - m); for(; i<=n && s-i; ++i){ int j = s - i, cur[3][3]; for(int a=0; a<3; ++a) cur[a][0] = cur[a][1] = cur[a][2] = 0; for(int a=0; a<3; ++a){ for(int b=0; b<3; ++b){ for(int c=0; c<3; ++c){ if(a == 1 && max(b, c) > a) continue; if(a == 1 && !up(i, j)) continue; if(a == 2 && !left(i, j)) continue; cur[a][b] = max(cur[a][b], bool(a) + dp[b][c]); } } } swap(dp, cur); } for(int a=0; a<3; ++a) for(int b=0; b<3; ++b) dp[0][0] = max(dp[0][0], dp[a][b]); for(int a=0; a<3; ++a) for(int b=0; b<3; ++b) dp[a][b] = dp[0][0]; } cout << dp[0][0]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...