Submission #499430

# Submission time Handle Problem Language Result Execution time Memory
499430 2021-12-28T11:56:45 Z Abito Kamenčići (COCI21_kamencici) C++14
70 / 70
1 ms 292 KB
#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
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 292 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct