#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);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
17 ms |
348 KB |
Output is correct |
8 |
Correct |
11 ms |
348 KB |
Output is correct |
9 |
Execution timed out |
1085 ms |
348 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
17 ms |
348 KB |
Output is correct |
8 |
Correct |
11 ms |
348 KB |
Output is correct |
9 |
Execution timed out |
1085 ms |
348 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |