#include <bits/stdc++.h>
using namespace std;
#define N 360
int dp[N][N][N];
int red[N];
int n, k;
int f(int i, int j, int l){
int m = red[n] - red[j] + red[i - 1] - l;
if(l >= k)
return 0;
if(m >= k)
return 1;
if(dp[i][j][k] != -1)
return dp[i][j][k];
return dp[i][j][k] = !f(i + 1, j, m) || !f(i, j - 1, m);
}
int main(){
memset(dp, -1, sizeof(dp));
string s;
cin >> n >> k >> s;
for(int i=1; i<=n; i++){
red[i] = red[i - 1];
if(s[i - 1] == 'C') red[i]++;
}
if(f(1, n, 0) == 1)
cout << "DA" << endl;
else cout << "NE" << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
79 ms |
182888 KB |
Output is correct |
2 |
Correct |
72 ms |
182876 KB |
Output is correct |
3 |
Correct |
70 ms |
182772 KB |
Output is correct |
4 |
Correct |
75 ms |
182772 KB |
Output is correct |
5 |
Incorrect |
72 ms |
182816 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
79 ms |
182888 KB |
Output is correct |
2 |
Correct |
72 ms |
182876 KB |
Output is correct |
3 |
Correct |
70 ms |
182772 KB |
Output is correct |
4 |
Correct |
75 ms |
182772 KB |
Output is correct |
5 |
Incorrect |
72 ms |
182816 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
79 ms |
182888 KB |
Output is correct |
2 |
Correct |
72 ms |
182876 KB |
Output is correct |
3 |
Correct |
70 ms |
182772 KB |
Output is correct |
4 |
Correct |
75 ms |
182772 KB |
Output is correct |
5 |
Incorrect |
72 ms |
182816 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |