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;
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--;
}
index = (index +1) % 2;
}
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |