#include <bits/stdc++.h>
using namespace std;
const int N = 355;
int n, k, dp[N][N][N];
string s;
int main(){
cin >> n >> k >> s;
for (int len = 1; len <= n; len ++){
for (int l = 0; l < n; l ++){
int r = l + len - 1;
int total = 0;
for (int i = 0; i < l; i ++)
total += (s[i] == 'C');
for (int i = r + 1; i < n; i ++)
total += (s[i] == 'C');
for (int c = 0; c <= total; c ++){
int o = total - c;
if (c >= k) dp[l][r][c] = 0;
else if (o >= k) dp[l][r][c] = 1;
else{
if (len == 1){
dp[l][r][c] = 0;
continue;
}
dp[l][r][c] = (!dp[l + 1][r][o] or !dp[l][r - 1][o]);
}
}
}
}
cout << (dp[0][n - 1][0] ? "DA" : "NE") << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
10584 KB |
Output is correct |
2 |
Correct |
1 ms |
10588 KB |
Output is correct |
3 |
Correct |
1 ms |
10588 KB |
Output is correct |
4 |
Correct |
1 ms |
10588 KB |
Output is correct |
5 |
Correct |
1 ms |
10588 KB |
Output is correct |
6 |
Correct |
1 ms |
10588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
10584 KB |
Output is correct |
2 |
Correct |
1 ms |
10588 KB |
Output is correct |
3 |
Correct |
1 ms |
10588 KB |
Output is correct |
4 |
Correct |
1 ms |
10588 KB |
Output is correct |
5 |
Correct |
1 ms |
10588 KB |
Output is correct |
6 |
Correct |
1 ms |
10588 KB |
Output is correct |
7 |
Correct |
3 ms |
24924 KB |
Output is correct |
8 |
Correct |
2 ms |
22900 KB |
Output is correct |
9 |
Correct |
3 ms |
24924 KB |
Output is correct |
10 |
Correct |
2 ms |
22944 KB |
Output is correct |
11 |
Correct |
2 ms |
22876 KB |
Output is correct |
12 |
Correct |
3 ms |
25056 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
10584 KB |
Output is correct |
2 |
Correct |
1 ms |
10588 KB |
Output is correct |
3 |
Correct |
1 ms |
10588 KB |
Output is correct |
4 |
Correct |
1 ms |
10588 KB |
Output is correct |
5 |
Correct |
1 ms |
10588 KB |
Output is correct |
6 |
Correct |
1 ms |
10588 KB |
Output is correct |
7 |
Correct |
3 ms |
24924 KB |
Output is correct |
8 |
Correct |
2 ms |
22900 KB |
Output is correct |
9 |
Correct |
3 ms |
24924 KB |
Output is correct |
10 |
Correct |
2 ms |
22944 KB |
Output is correct |
11 |
Correct |
2 ms |
22876 KB |
Output is correct |
12 |
Correct |
3 ms |
25056 KB |
Output is correct |
13 |
Correct |
94 ms |
172116 KB |
Output is correct |
14 |
Correct |
77 ms |
171088 KB |
Output is correct |
15 |
Correct |
68 ms |
156760 KB |
Output is correct |
16 |
Correct |
88 ms |
169556 KB |
Output is correct |
17 |
Correct |
97 ms |
170320 KB |
Output is correct |
18 |
Correct |
86 ms |
169556 KB |
Output is correct |