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>
#define ll long long int
#define F first
#define S second
#define pb push_back
using namespace std;
int main()
{
ll n,k;
cin>>n>>k;
string s;
cin>>s;
ll first=0;
ll second=0;
ll r=n-1;
ll l=0;
while (first!=k&&second!=k)
{
if (s[l]=='P')
{
l++;
}else if (s[r]=='P')
{
r--;
}
else
{
if (s[l+1]=='C')
{
l++;
}
else
{
r--;
}
first++;
}
if (first==k)break;
if (s[l]=='P')
{
l++;
}else if (s[r]=='P')
{
r--;
}
else
{
if (s[l+1]=='P')
{
l++;
}
else
{
r--;
}
second++;
}
}
if (first==k)
cout<<"NE"<<endl;
else
cout<<"DA"<<endl;
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... |