#include <cstdio>
#include <stdio.h>
#include <stdbool.h>
#include <iostream>
#include <map>
#include <vector>
#include <climits>
#include <stack>
#include <string>
#include <queue>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <cctype>
#include <bitset>
#include <iomanip>
#include <cstring>
#include <numeric>
#include <cassert>
#include <random>
#include <chrono>
#include <fstream>
using namespace std;
#define int long long
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
int n, k, dp[355][355][355];
string s;
bool win(bool t, int l, int r, int a, int b){
if (a>=k||b>=k)return 1;
if (dp[l][r][a]!=-1)return dp[l][r][a];
if (t)dp[l][r][a]=!win(!t, l+1, r, a+(s[l]=='C'), b)||!win(!t, l, r-1, a+(s[r]=='C'), b);
else dp[l][r][a]=!win(!t, l+1, r, a, b+(s[l]=='C'))||!win(!t, l, r-1, a, b+(s[r]=='C'));
return dp[l][r][a];
}
int32_t main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>k>>s;
for (int i=0; i<355; ++i)for (int j=0; j<355; ++j)for (int p=0; p<355; ++p)dp[i][j][p]=-1;
cout<<(win(1, 0, n-1, 0, 0)?"DA":"NE");
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |