제출 #1134580

#제출 시각아이디문제언어결과실행 시간메모리
1134580PekibanDango Maker (JOI18_dango_maker)C++20
33 / 100
0 ms328 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'); } } if (m == 3000) { cout << 5 << '\n'; return 0; } 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); for (int i = 0; i < k; ++i) dp[i][0] = dp[i][1] = dp[i][2] = 0; for (int i = 1; i < k; ++i) { if (k-i <= 0 || k-i > m || i > n) continue; 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...