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>
#define ll long long
#define endl "\n"
#define fastIO cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false);
#define mid ((l + r) / 2)
#define lChild ((index * 2) + 1)
#define rChild ((index * 2) + 2)
using namespace std;
struct node {
ll t, a, b;
};
bool get(string& s, ll l, ll r, ll k, vector<ll>& score, bool round) {
/* cout<<round + 1<< " => "<<l<<" "<<r<<endl;
cout<<"Score: "<<score[0]<<" "<<score[1]<<endl;*/
if(score[0] == k) return false;
else if(score[1] == k) return true;
bool ans = round;
score[round] += s[l] == 'C';
if(!round) ans |= get(s, l + 1, r, k, score, !round);
else ans &= get(s, l + 1, r, k, score, !round);
score[round] -= s[l] == 'C';
score[round] += s[r] == 'C';
if(!round) ans |= get(s, l, r - 1, k, score, !round);
else ans &= get(s, l, r - 1, k, score, !round);
score[round] -= s[r] == 'C';
return ans;
}
void solve(ll _) {
ll n, k; cin>>n>>k;
string s; cin>>s;
vector<ll> scores = {0, 0};
cout<<(get(s, 0, n - 1, k, scores, 0) ? "DA" : "NE")<<endl;
}
int main() {
fastIO
//freopen("file.in", "r", stdin);
//freopen("file.out", "w", stdout);
ll t = 0; solve(t);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |