Submission #1255099

#TimeUsernameProblemLanguageResultExecution timeMemory
1255099wedonttalkanymoreDango Maker (JOI18_dango_maker)C++20
13 / 100
1 ms584 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define int long long #define pii pair<ll, ll> #define fi first #define se second const ll N = 6e3 + 5, inf = 1e18, mod = 1e9 + 7, block = 320, lim = 1 << 16; int n, m; char a[N][N]; int dp[N][3]; bool check1(int x, int y) { return (a[x][y] == 'R' && a[x + 1][y] == 'G' && a[x + 2][y] == 'W'); } bool check2(int x, int y) { return (a[x][y] == 'R' && a[x][y + 1] == 'G' && a[x][y + 2] == 'W'); } signed main() { ios::sync_with_stdio(false); cin.tie(0); if (fopen(".inp", "r")) { freopen(".inp", "r", stdin); freopen(".out", "w", stdout); } cin >> n >> m; for (int i = 1; i <= n; i++) { string s; cin >> s; for (int j = 1; j <= m; j++) { a[i][j] = s[j - 1]; } } int ans = 0; for (int i = 2; i <= n + m; i++) { // xet den o i memset(dp, 0, sizeof(dp)); int res = 0; for (int j = min(i - 1, m), k = i - j; j > 0 && k <= n; j--, k++) { dp[j][0] = max(dp[j + 1][0], dp[j + 3][1]) + check2(k, j); // hang -> bo qua 2 con den con i + 3 dp[j][1] = max(dp[j + 1][0], dp[j + 3][1]) + check1(k, j); // cot res = max({res, dp[j][0], dp[j][1]}); } ans += res; } cout << ans; return 0; }

Compilation message (stderr)

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