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"iostream"
// #include"vector"
// #include"queue"
// #include"deque"
// #include"set"
// #include"map"
// #include"algorithm"
// #include"cstring"
// #define int long long
using namespace std;
void solve(){
int n,k;
cin >> n >> k;
string str;
cin >> str;
int turn = 1; // 1->Antun(DA) | 2-> Branka(NE)
int red0=0,red1=0;
for(int i=0;i<n;i++){
if(turn==1){
if(str[0]=='P'){
str = str.substr(1,str.length()-1);
}
else if(str[str.length()-1]=='P'){
str = str.substr(0,str.length()-1);
}
else{
str = str.substr(1,str.length()-1);
red1++;
}
if(red1==k){
cout << "NE\n";return;
}
turn=0;
}
else{
if(str[0]=='P'){
str = str.substr(1,str.length()-1);
}
else if(str[str.length()-1]=='P'){
str = str.substr(0,str.length()-1);
}
else{
str = str.substr(1,str.length()-1);
red0++;
}
if(red0==k){
cout << "DA\n";return;
}
turn=1;
}
// cout << str << "\n";
}
}
signed main(){
ios::sync_with_stdio(false); cin.tie(0);
// freopen("","r",stdin);freopen("","w",stdout);
int t=1;
// cin >>t;
for(int i=1;i<=t;i++){
// cout << "Case " << i << ":\n";
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |