Submission #654291

#TimeUsernameProblemLanguageResultExecution timeMemory
654291lunchbox1Dango Maker (JOI18_dango_maker)C++17
0 / 100
1 ms340 KiB
/* Dango Maker https://oj.uz/problem/view/JOI18_dango_maker */ #include <bits/stdc++.h> using namespace std; const int N = 3e3; int main() { ios::sync_with_stdio(0), cin.tie(0); int n, m; cin >> n >> m; static string s[N]; for (int i = 0; i < n; i++) cin >> s[i]; static int f[N][3]; int ans = 0; for (int k = 0; k < n + m - 1; k++) { int p = -1; for (int i = 0; i < n; i++) { int j = k - i; if (j < 0 || j >= m) continue; f[i][0] = f[i][1] = f[i][2] = 0; if (p == -1) { if (j > 0 && j < m - 1 && s[i][j - 1] == 'R' && s[i][j] == 'G' && s[i][j + 1] == 'W') f[i][1] = 1; if (i > 0 && i < n - 1 && s[i - 1][j] == 'R' && s[i][j] == 'G' && s[i + 1][j] == 'W') f[i][2] = 1; } else { f[i][0] = max({f[p][0], f[p][1], f[p][2]}); if (j > 0 && j < m - 1 && s[i][j - 1] == 'R' && s[i][j] == 'G' && s[i][j + 1] == 'W') f[i][1] = max(f[p][0], f[p][2]) + 1; if (i > 0 && i < n - 1 && s[i - 1][j] == 'R' && s[i][j] == 'G' && s[i + 1][j] == 'W') f[i][2] = max(f[p][0], f[p][1]) + 1; } p = i; } ans += max({f[p][0], f[p][1], f[p][2]}); } cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...