Submission #1128989

#TimeUsernameProblemLanguageResultExecution timeMemory
1128989LeonaRagingDango Maker (JOI18_dango_maker)C++20
100 / 100
279 ms115292 KiB
#include<bits/stdc++.h> using namespace std; const int N = 3005; int n, m, dp[N][N][3]; string s[N]; bool ok_row(int i, int j) { return (j > 1 && j < m && s[i][j - 1] == 'R' && s[i][j] == 'G' && s[i][j + 1] == 'W'); } bool ok_col(int i, int j) { return (i > 1 && i < n && s[i - 1][j] == 'R' && s[i][j] == 'G' && s[i + 1][j] == 'W'); } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen(".INP", "r")) { freopen(".INP", "r", stdin); freopen(".OUT", "w", stdout); } cin >> n >> m; for (int i = 1; i <= n; i++) cin >> s[i], s[i] = ' ' + s[i]; int res = 0; for (int S = 2; S <= n + m; S++) { for (int i = min(n, S - 1); i >= max(1, S - m); i--) { int j = S - i; dp[i][j][0] = max({dp[i + 1][j - 1][0], dp[i + 1][j - 1][1], dp[i + 1][j - 1][2]}); if (ok_row(i, j)) dp[i][j][1] = max({dp[i + 1][j - 1][0], dp[i + 1][j - 1][1]}) + 1; if (ok_col(i, j)) dp[i][j][2] = max({dp[i + 1][j - 1][0], dp[i + 1][j - 1][2]}) + 1; res -= max({dp[i + 1][j - 1][0], dp[i + 1][j - 1][1], dp[i + 1][j - 1][2]}); res += max({dp[i][j][0], dp[i][j][1], dp[i][j][2]}); } } cout << res; }

Compilation message (stderr)

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:22:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |                 freopen(".INP", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~
dango_maker.cpp:23:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |                 freopen(".OUT", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...