Submission #1032705

#TimeUsernameProblemLanguageResultExecution timeMemory
1032705vjudge1Kamenčići (COCI21_kamencici)C++17
70 / 70
97 ms172116 KiB
#include <bits/stdc++.h> using namespace std; const int N = 355; int n, k, dp[N][N][N]; string s; int main(){ cin >> n >> k >> s; for (int len = 1; len <= n; len ++){ for (int l = 0; l < n; l ++){ int r = l + len - 1; int total = 0; for (int i = 0; i < l; i ++) total += (s[i] == 'C'); for (int i = r + 1; i < n; i ++) total += (s[i] == 'C'); for (int c = 0; c <= total; c ++){ int o = total - c; if (c >= k) dp[l][r][c] = 0; else if (o >= k) dp[l][r][c] = 1; else{ if (len == 1){ dp[l][r][c] = 0; continue; } dp[l][r][c] = (!dp[l + 1][r][o] or !dp[l][r - 1][o]); } } } } cout << (dp[0][n - 1][0] ? "DA" : "NE") << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...