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;
using ll = long long;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(0);
int n,k;
string s;
cin >> n >> k >> s;
int l = 0;
int r = n-1;
int k1 = 0;
int k2 = 0;
bool antun = true;
while(l <= r){
if(antun){
antun = false;
if(s[l] == 'P'){
l++;
}else if(s[r] == 'P'){
r--;
}else{
l++;
k1++;
if(k1 == k){
cout << "NE";
return 0;
}
}
}else{
antun = true;
if(s[l] == 'P'){
l++;
}else if(s[r] == 'P'){
r--;
}else{
l++;
k2++;
if(k2 == k){
cout << "DA";
return 0;
}
}
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |