Submission #499451

#TimeUsernameProblemLanguageResultExecution timeMemory
499451adamKamenčići (COCI21_kamencici)C++14
70 / 70
1 ms292 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...