#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
int n,k;
string s;
int dp[355][355][355];
vector<int> prefix, suffix;
int solve(int l,int r,int cnt){
bool turn = (l + n-r-1)&1;
if(l>r) return turn;
if(cnt==k) return (turn);
int rem = prefix[l] + suffix[r] - cnt;
if(rem == k) return !turn;
int &ret = dp[l][r][cnt];
if(~ret) return ret;
bool c1 = solve(l+1,r,cnt+(s[l]=='C'&&!turn));
bool c2 = solve(l,r-1,cnt+(s[r]=='C'&&!turn));
return ret = !(c1&c2);
}
void solve(){
cin>>n>>k;
cin>>s;
prefix.resize(n), suffix.resize(n);
for(int i=1;i<=n;i++) prefix[i] = (s[i-1] == 'C') + prefix[i-1];
for(int i=n-2;i>=0;i--) suffix[i] = (s[i+1] == 'C') + suffix[i+1];
memset(dp,-1,sizeof(dp));
cout<<(solve(0,n-1,0)?"DA":"NE")<<endl;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t=1;
//cin>>t;
while(t--){
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
163 ms |
355712 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
163 ms |
355712 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
163 ms |
355712 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |