Submission #391742

#TimeUsernameProblemLanguageResultExecution timeMemory
391742timmyfengDango Maker (JOI18_dango_maker)C++17
100 / 100
204 ms52468 KiB
#include <bits/stdc++.h> using namespace std; const int N = 3000; bool dango[2 * N][N][2]; string grid[N]; int n, m; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> m; for (int i = 0; i < n; ++i) { cin >> grid[i]; } for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { dango[i + j][i][0] = i < n - 2 && grid[i][j] == 'R' && grid[i + 1][j] == 'G' && grid[i + 2][j] == 'W'; dango[i + j][i][1] = j < m - 2 && grid[i][j] == 'R' && grid[i][j + 1] == 'G' && grid[i][j + 2] == 'W'; } } int ans = 0; for (int i = 0; i < n + m; ++i) { int one = 0, two = 0, three = 0; for (int j = 0; j < n; ++j) { three = max(three + dango[i][j][1], two); two = one, one = one + dango[i][j][0]; one = max({one, two, three}); two = max(two, three); } ans += max({one, two, three}); } cout << ans << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...