Submission #1265526

#TimeUsernameProblemLanguageResultExecution timeMemory
1265526namhhKamenčići (COCI21_kamencici)C++20
70 / 70
52 ms86852 KiB
#include<bits/stdc++.h> using namespace std; #define pii pair<int,int> #define fi first #define se second const int N = 355; int n,k,a[N],dp[N][N][N]; string s; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> k >> s; s = "#"+s; for(int len = 1; len <= n; len++){ for(int l = 1; l+len-1 <= n; l++){ int r = l+len-1; int lim = 0; for(int i = 1; i < l; i++) lim += (s[i] == 'C'); for(int i = r+1; i <= n; i++) lim += (s[i] == 'C'); for(int i = 0; i <= lim; i++){ int rem = lim-i; if(rem >= k) dp[l][r][i] = 1; else if(i < k && rem < k) dp[l][r][i] = 1-min(dp[l+1][r][rem],dp[l][r-1][rem]); } } } if(dp[1][n][0] == 1) cout << "DA"; else cout << "NE"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...