Submission #862214

#TimeUsernameProblemLanguageResultExecution timeMemory
862214TAhmed33Kamenčići (COCI21_kamencici)C++98
70 / 70
58 ms169900 KiB
#include <bits/stdc++.h> using namespace std; int dp[351][351][351]; int arr[351]; int n, k; int ans (int l, int r, int c, int c2) { if (c == k || c2 == k) return 1; int &ret = dp[l][r][c]; if (ret != -1) return ret; int x = r - l + 1; ret = 0; if ((x & 1) == (n & 1)) { ret |= !ans(l + 1, r, c + arr[l], c2); ret |= !ans(l, r - 1, c + arr[r], c2); } else { ret |= !ans(l + 1, r, c, c2 + arr[l]); ret |= !ans(l, r - 1, c, c2 + arr[r]); } return ret; } int main () { memset(dp, -1, sizeof(dp)); cin >> n >> k; for (int i = 1; i <= n; i++) { char x; cin >> x; arr[i] = (x == 'C'); } cout << (ans(1, n, 0, 0) ? "DA\n" : "NE\n"); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...