Submission #898785

#TimeUsernameProblemLanguageResultExecution timeMemory
898785duckindogKamenčići (COCI21_kamencici)C++14
70 / 70
76 ms365908 KiB
// from duckindog wth depression #include<bits/stdc++.h> using namespace std; const int N = 350 + 10; int n, k; int a[N], d[N]; int f[N][N][2][N]; bool dp(int l, int r, int t, int x) { if (x == k) return 0; if (d[l - 1] + d[n] - d[r] - x == k) return 1; auto &ret = f[l][r][t][x]; if (ret > -1) return ret; if (t) { auto lt = dp(l + 1, r, 1 - t, x + a[l]); auto rt = dp(l, r - 1, 1 - t, x + a[r]); ret = lt | rt; } else { auto lt = dp(l + 1, r, 1 - t, x); auto rt = dp(l, r - 1, 1 - t, x); ret = lt & rt; } return ret; } int32_t main() { cin.tie(0)->sync_with_stdio(0); if (fopen("duck.inp", "r")) { freopen("duck.out", "w", stdout); freopen("duck.inp", "r", stdin); } memset(f, -1, sizeof f); cin >> n >> k; for (int i = 1; i <= n; ++i) { char x; cin >> x; a[i] = x == 'C'; d[i] = d[i - 1] + a[i]; } cout << (dp(1, n, 1, 0) == 1 ? "DA" : "NE"); }

Compilation message (stderr)

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