Submission #1187775

#TimeUsernameProblemLanguageResultExecution timeMemory
1187775M_W_13Dango Maker (JOI18_dango_maker)C++20
100 / 100
216 ms26884 KiB
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) typedef long long ll; #define pb push_back #define st first #define nd second int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; char T[n][m]; bool czy[n][m][2]; rep(i, n) { rep(j, m) { cin >> T[i][j]; czy[i][j][0] = false; czy[i][j][1] = false; if (j >= 2 && T[i][j - 2] == 'R' && T[i][j - 1] == 'G' && T[i][j] == 'W') { czy[i][j][0] = true; } if (i >= 2 && T[i - 2][j] == 'R' && T[i - 1][j] == 'G' && T[i][j] == 'W') { czy[i][j][1] = true; } } } int dp[n + 1][3]; int ans = 0; for (int s = 0; s < n + m - 1; s++) { dp[0][0] = 0; dp[0][1] = 0; dp[0][2] = 0; // cout << "s = " << s << '\n'; rep(x, n) { int y = s - x; dp[x + 1][0] = dp[x][0]; dp[x + 1][1] = dp[x][0]; dp[x + 1][2] = dp[x][1]; if (y >= m) { continue; } if (y < 0) { // cout << "ile = " << dp[x][0] << '\n'; ans += dp[x][0]; break; } if (czy[x][y][0]) { dp[x + 1][0]++; } if (czy[x][y][1]) { dp[x + 1][1] = max(dp[x + 1][1], dp[x][2] + 1); dp[x + 1][2] = max(dp[x + 1][2], dp[x][2] + 1); } dp[x + 1][0] = max(dp[x + 1][0], max(dp[x + 1][1], dp[x + 1][2])); } if (s >= n - 1) { // cout << "ile = " << dp[n][0] << '\n'; ans += dp[n][0]; } } cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...