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;
int n, k;
string s;
bool fun(int l = 0, int r = n - 1, int a = 0, int b = 0)
{
if(a == k || b == k)
return b == k;
if(!(n - (r - l + 1) & 1))
{
return fun(l + 1, r, a + (s[l] == 'C'), b) || fun(l, r - 1, a + (s[r] == 'C'), b);
}
else
{
return !(!fun(l + 1, r, a, b + (s[l] == 'C')) || !fun(l, r - 1, a, b + (s[r] == 'C')));
}
}
int main()
{
cin>>n>>k;
cin>>s;
cout<<(fun() ? "DA" : "NE");
}
Compilation message (stderr)
Main.cpp: In function 'bool fun(int, int, int, int)':
Main.cpp:9:12: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
9 | if(!(n - (r - l + 1) & 1))
| ~~^~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |