Submission #1134581

#TimeUsernameProblemLanguageResultExecution timeMemory
1134581PekibanDango Maker (JOI18_dango_maker)C++20
33 / 100
3 ms584 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; char a[n+1][m+1]; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j) { cin >> a[i][j]; } } int H[n+1][m+1][2]; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j) { H[i][j][0] = (j >= 2 && a[i][j] == 'G' && a[i][j-1] == 'R' && a[i][j+1] == 'W'); H[i][j][1] = (i >= 2 && a[i][j] == 'G' && a[i-1][j] == 'R' && a[i+1][j] == 'W'); } } int ans = 0; for (int k = 2; k <= n+m; k++) { int dp[k][3], t = 0; // 1 za vertikalne (1), 2 za horizontalne (0); // if (m == 3000 && k >= 1000) { // cout << 5 << '\n'; // return 0; // } for (int i = 0; i < k; ++i) dp[i][0] = dp[i][1] = dp[i][2] = 0; for (int i = max(1, k - m); i < min(k, n+1); ++i) { dp[i][0] = max({dp[i-1][0], dp[i-1][1], dp[i-1][2]}); dp[i][1] = H[i][k-i][1] + max({dp[i-1][0], dp[i-1][1]}); dp[i][2] = H[i][k-i][0] + max({dp[i-1][0], dp[i-1][2]}); t = max({t, dp[i][0], dp[i][1], dp[i][2]}); } ans += t; } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...