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,red=0,red2=0;
cin>>n>>k;
int i=0,j=n-1;
bool a[n]={0};
string s;
cin>>s;
while (i<j && (red<k || red2<k))
{
if (s[i]=='P')
{
a[i]=1;
i++;
}
else if (s[j]=='P')
{
a[j]=1;
j--;
}
else if (s[i]=='C' && s[i+1]=='C')
{
a[i]=1;
red++;
i++;
}
else if (s[j]=='C' && s[j-1]=='C')
{
a[j]=1;
red++;
j--;
}
else if (s[i]=='C')
{
a[i]=1;
red++;
i++;
}
if (red>=k)
break;
if (s[i]=='P')
{
a[i]=1;
i++;
}
else if (s[j]=='P')
{
a[j]=1;
j--;
}
else if (s[i]=='C' && s[i+1]=='C')
{
a[i]=1;
red2++;
i++;
}
else if (s[j]=='C' && s[j-1]=='C')
{
a[j]=1;
red2++;
j--;
}
else if (s[i]=='C')
{
a[i]=1;
red2++;
i++;
}
if (red2>=k)
break;
}
if (red2>red)
{
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... |