This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |