Submission #861736

#TimeUsernameProblemLanguageResultExecution timeMemory
861736Cyber_WolfKamenčići (COCI21_kamencici)C++17
70 / 70
109 ms501364 KiB
#include <bits/stdc++.h> using namespace std; #define lg long long const lg N = 400; lg dp[N][N][N], pref[N]; lg n, k; string s; lg solve(lg l, lg r, lg o) { if(o >= k) return 0; if(pref[l-1]+pref[n]-pref[r]-o >= k) return 1; auto&ret = dp[l][r][o]; if(~ret) return ret; if((l-1+n-r)%2) { ret = min(solve(l+1, r, o), solve(l, r-1, o)); } else{ ret = max(solve(l+1, r, o+(s[l-1] == 'C')), solve(l, r-1, o+(s[r-1] == 'C'))); } // cout << l << ' ' << r << ' ' << o << '\n'; // cout << ret << '\n'; return ret; } int main() { cin >> n >> k; cin >> s; for(int i = 1; i <= n; i++) { pref[i] = pref[i-1]+(s[i-1] == 'C'); } memset(dp, -1, sizeof(dp)); cout << (solve(1, n, 0) ? "DA" : "NE") << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...