#include <bits/stdc++.h>
using namespace std;
int ans[2];
void answer() {
int n, k;
cin >> n >> k;
string s;
cin >> s;
int i = 0, j = n-1;
int index = 1;
while(ans[0] != k && ans[1] != k) {
index = (index +1) % 2;
if(i == j) {
if(s[i] == 'C') {
ans[index]++;
}
continue;
}
char ch1 =s[i], ch2=s[j];
if(ch1 != 'C' && ch2 == 'C') {
i++;
continue;
}
if(ch1 == 'C' && ch2 != 'C') {
j--;
continue;
}
if(ch1 == 'C' && ch2 =='C') {
if(s[i+1] == 'P')
j--;
else i++;
ans[index]++;
}
if(ch1 == 'P' && ch2 =='P'){
if(s[i+1] == 'P'){
i++;
} else j--;
}
}
if(ans[0] >= k){
cout << "NE";
} else
cout << "DA";
}
int main() {
int t=1;
// cin >> t;
while(t--)
answer();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |