#include <iostream>
using namespace std;
int main(){
int n;
int k;
cin>>n>>k;
string c;
cin>>c;
string h=c;
bool f=true;
bool d=false;
int a=0;
int b=0;
for(int i=0;i<n;i++){
if(f==true){
if(c[i]=='C'){
a+=1;
}
}
else if(f==false){
if(c[i]=='C'){
b+=1;
}
if(f==true){
f=false;
}
else if(f==false){
f=true;
}
}
if(b>=k&&a<k){
cout<<"DA";
d=true;
break;
}
}
if(d==false) {
c=h;
a=0;
b=0;
f=true;
for(int i=0;i<n;i++){
if(f==true){
if(c[i]=='C'){
a++;
c[i]=' ';
}
}
if(f==false){
if(c[n-1-i]=='C'){
b++;
c[n-1-i]=' ';
}
}
if(f==true){
f=false;
}
else if(f==false){
f=true;
}
if(b>=k&&a<k){
d=true;
cout<<"DA";
break;
}
}
if(d==false) {
d=false;
c=h;
a=0;
b=0;
f=true;
for(int i=0;i<n;i++){
if(f==true){
if(c[n-1-i]=='C'){
a++;
c[n-1-i]=' ';
}
else if(f==false){
if(c[i]=='C'){
b++;
c[i]=' ';
}
}
if(b>=k&&a<k){
d=true;
cout<<"DA";
break;
}
if(f==true){
f=false;
}
else if(f==false){
f=true;
}
}
}
}
}
if(d==false) {
d=false;
c=h;
a=0;
b=0;
f=true;
for(int i=0;i<n;i++){
if(f==true){
if(c[n-1-i]=='C'){
a+=1;
}
}
if(f==false){
if(c[n-1-i]=='C'){
b+=1;
}
}
if(b>=k&&a<k){
d=true;
cout<<"DA";
break;
}
if(f==true){
f=false;
}
else if(f==false){
f=true;
}
}
}
if(d==false){
cout<<"NE";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
296 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
296 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
296 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |