Submission #887987

#TimeUsernameProblemLanguageResultExecution timeMemory
887987hafoDango Maker (JOI18_dango_maker)C++14
13 / 100
0 ms432 KiB
#include <bits/stdc++.h> #define ll long long #define ull unsigned ll #define pb push_back #define pa pair<int, int> #define pall pair<ll, int> #define fi first #define se second #define TASK "test" #define Size(x) (int) x.size() #define all(x) x.begin(), x.end() using namespace std; template<typename T1, typename T2> bool mini (T1 &a, T2 b) {if(a > b) a = b; else return 0; return 1;} template<typename T1, typename T2> bool maxi (T1 &a, T2 b) {if(a < b) a = b; else return 0; return 1;} const int MOD = 1e9 + 7; const int LOG = 20; const int maxn = 3e3 + 7; const ll oo = 1e18 + 69; int n, m, dp[maxn][3]; char a[maxn][maxn]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); //freopen(TASK".inp", "r", stdin); //freopen(TASK".out", "w", stdout); cin>>n>>m; for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) cin>>a[i][j]; } int ans = 0; for(int d = 0; d <= n + m; d++) { for(int i = 0; i <= n; i++) { for(int t = 0; t < 3; t++) dp[i][t] = 0; } for(int i = 1; i <= n; i++) { int j = d - i; maxi(dp[i][0], dp[i - 1][0]); maxi(dp[i][1], dp[i - 1][1]); maxi(dp[i][2], dp[i - 1][2]); maxi(dp[i][1], dp[i][0]); if(j > m || j < 1) continue; if(j - 2 >= 1 && a[i][j] == 'W' && a[i][j - 1] == 'G' && a[i][j - 2] == 'R') dp[i][1]++; if(i - 3 >= 0 && a[i][j] == 'W' && a[i - 1][j] == 'G' && a[i - 2][j] == 'R') { maxi(dp[i][2], max(dp[i - 3][1], dp[i - 3][2]) + 1); maxi(dp[i][2], max(dp[i - 1][2], dp[i - 1][0]) + 1); } } ans += max(dp[n][1], dp[n][2]); } cout<<ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...