Submission #527905

#TimeUsernameProblemLanguageResultExecution timeMemory
527905Jarif_RahmanKamenčići (COCI21_kamencici)C++17
0 / 70
1 ms576 KiB
#include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; int dp[350][350][350]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n, k; cin >> n >> k; string s; cin >> s; for(int i = 0; i < n; i++){ if((n-1)%2 == 1 && s[i] == 'C') dp[i][i][0] = 1; } for(int sz = 2; sz <= n; sz++) for(int i = 0; i+sz-1 < n; i++){ int j = i+sz-1; for(int kk = 0; kk < n; kk++){ if(kk != 0) dp[i][j][kk] = dp[i][j][kk-1]; if((n-sz)%2 == 1){ dp[i][j][kk] = min(dp[i+1][j][kk]+ (s[i]=='C'), dp[i][j-1][kk]+(s[j]=='C')); } if((n-sz)%2 == 0){ if(kk == 0){ if(s[i] != 'C') dp[i][j][kk] = max(dp[i][j][kk], dp[i+1][j][kk]); if(s[j] != 'C') dp[i][j][kk] = max(dp[i][j][kk], dp[i][j-1][kk]); continue; } dp[i][j][kk] = max(dp[i+1][j][kk-(s[i]=='C')], dp[i][j-1][kk-(s[i]=='C')]); } } } if(dp[0][n-1][k-1] >= k) cout << "DA\n"; else cout << "NE\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...