Submission #771991

#TimeUsernameProblemLanguageResultExecution timeMemory
7719911binDango Maker (JOI18_dango_maker)C++14
100 / 100
128 ms19012 KiB
#include <bits/stdc++.h> using namespace std; #define all(v) v.beign(), v.end() typedef long long ll; const int NMAX = 3005; int n, m, ans, dp[NMAX][3], x, y; string s[NMAX]; int main(void){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for(int i = 0; i < n; i++) cin >> s[i]; for(int i = 0; i < n + m - 1; i++){ for(int j = 0; j < m; j++) for(int k = 0; k < 3; k++) dp[j][k] = 0; if(i < n) y = i, x = 0; else y = n - 1, x = i - n + 1; while(y >= 0 && x < m){ if(x) dp[x][0] = max({dp[x - 1][0], dp[x - 1][1], dp[x - 1][2]}); if(s[y][x] == 'G'){ if(x && x + 1 < m && s[y][x - 1] == 'R' && s[y][x + 1] == 'W') dp[x][1] = max(dp[x - 1][0], dp[x - 1][1]) + 1; if(y && y + 1 < n && s[y - 1][x] == 'R' && s[y + 1][x] == 'W') { if(!x) dp[x][2] = 1; else dp[x][2] = max(dp[x - 1][0], dp[x - 1][2]) + 1; } } x++; y--; } x--; ans += max({dp[x][0], dp[x][1], dp[x][2]}); } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...