Submission #499436

# Submission time Handle Problem Language Result Execution time Memory
499436 2021-12-28T12:11:19 Z Haboosh915 Kamenčići (COCI21_kamencici) C++17
70 / 70
1 ms 204 KB
#include <bits/stdc++.h>

using namespace std;
int main()
{
    int n , k , kf = 0 , ks = 0 ;
    cin >> n >> k ;
    int i = 0 ,j = n-1;

    string s;
    cin >>s ;
    while (i < j && (kf < k || ks <k) ){
        if (s[i]=='P'){
            i++;
        }
        else if (s[j]=='P'){
            j--;
        }
        else if (s[i]=='C' && s[i+1]=='C'){
            kf++;
            i++;
        }
        else if (s[j]=='C' && s[j-1]=='C'){
            kf++;
            j--;
        }
        else if (s[i]=='C'){
            kf++;
            i++;
        }

        if (kf >= k) break;

        if (s[i]=='P'){
            i++;
        }
        else if (s[j]=='P'){
            j--;
        }
        else if (s[i]=='C' && s[i+1]=='C'){
            ks++;
            i++;
        }
        else if (s[j]=='C' && s[j-1]=='C'){
            ks++;
            j--;
        }
        else if (s[i]=='C'){
            ks++;
            i++;
        }

        if (ks >= k)break;

    }

    if ( ks > kf ) 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 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 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct