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 main()
{
int n , k , kf = 0 , ks = 0 ;
cin >> n >> k ;
int i = 0 ,j = n-1;
string s;
cin >>s ;
while (i < j && (kf < k || ks <k) ){
if (s[i]=='P'){
i++;
}
else if (s[j]=='P'){
j--;
}
else if (s[i]=='C' && s[i+1]=='C'){
kf++;
i++;
}
else if (s[j]=='C' && s[j-1]=='C'){
kf++;
j--;
}
else if (s[i]=='C'){
kf++;
i++;
}
if (kf >= k) break;
if (s[i]=='P'){
i++;
}
else if (s[j]=='P'){
j--;
}
else if (s[i]=='C' && s[i+1]=='C'){
ks++;
i++;
}
else if (s[j]=='C' && s[j-1]=='C'){
ks++;
j--;
}
else if (s[i]=='C'){
ks++;
i++;
}
if (ks >= k)break;
}
if ( ks > kf ) cout << "DA" ;
else cout<<"NE";
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... |