이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |