#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const int N=355;
int n,k,dp[N][N][N],pre[N];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
memset(dp, -1, sizeof dp);
cin>>n>>k;
string str;
cin>>str;
str=str;
for(int i=1;i<=n;i++)pre[i]=pre[i-1]+(str[i-1]=='C');
for(int l=n;l>=1;l--){
for(int r=l;r<=n;r++){
for(int cnt=0;cnt<=n;cnt++){
if(cnt>=k){
dp[l][r][cnt]=0;
continue;
}
int cnt2=pre[n]-cnt-(pre[r]-pre[l-1]);
if(cnt2>=k)dp[l][r][cnt]=1;
else dp[l][r][cnt]=(!dp[l+1][r][cnt2])||(!dp[l][r-1][cnt2]);
}
}
}
cout<<(dp[1][n][0]?"DA\n":"NE\n");
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
175308 KB |
Output is correct |
2 |
Correct |
27 ms |
175536 KB |
Output is correct |
3 |
Correct |
28 ms |
175488 KB |
Output is correct |
4 |
Correct |
27 ms |
175388 KB |
Output is correct |
5 |
Correct |
29 ms |
175696 KB |
Output is correct |
6 |
Correct |
30 ms |
175296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
175308 KB |
Output is correct |
2 |
Correct |
27 ms |
175536 KB |
Output is correct |
3 |
Correct |
28 ms |
175488 KB |
Output is correct |
4 |
Correct |
27 ms |
175388 KB |
Output is correct |
5 |
Correct |
29 ms |
175696 KB |
Output is correct |
6 |
Correct |
30 ms |
175296 KB |
Output is correct |
7 |
Correct |
30 ms |
175444 KB |
Output is correct |
8 |
Correct |
27 ms |
175352 KB |
Output is correct |
9 |
Correct |
27 ms |
175444 KB |
Output is correct |
10 |
Correct |
27 ms |
175440 KB |
Output is correct |
11 |
Correct |
31 ms |
175440 KB |
Output is correct |
12 |
Correct |
30 ms |
175452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
175308 KB |
Output is correct |
2 |
Correct |
27 ms |
175536 KB |
Output is correct |
3 |
Correct |
28 ms |
175488 KB |
Output is correct |
4 |
Correct |
27 ms |
175388 KB |
Output is correct |
5 |
Correct |
29 ms |
175696 KB |
Output is correct |
6 |
Correct |
30 ms |
175296 KB |
Output is correct |
7 |
Correct |
30 ms |
175444 KB |
Output is correct |
8 |
Correct |
27 ms |
175352 KB |
Output is correct |
9 |
Correct |
27 ms |
175444 KB |
Output is correct |
10 |
Correct |
27 ms |
175440 KB |
Output is correct |
11 |
Correct |
31 ms |
175440 KB |
Output is correct |
12 |
Correct |
30 ms |
175452 KB |
Output is correct |
13 |
Correct |
38 ms |
175504 KB |
Output is correct |
14 |
Correct |
40 ms |
175444 KB |
Output is correct |
15 |
Correct |
36 ms |
175448 KB |
Output is correct |
16 |
Correct |
39 ms |
175440 KB |
Output is correct |
17 |
Correct |
42 ms |
175452 KB |
Output is correct |
18 |
Correct |
38 ms |
175452 KB |
Output is correct |