Submission #869518

# Submission time Handle Problem Language Result Execution time Memory
869518 2023-11-04T15:36:10 Z JoksimKaktus Kamenčići (COCI21_kamencici) C++17
0 / 70
0 ms 348 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    int n,k;
    string s;
    cin >> n >> k >> s;
    int l = 0;
    int r = n-1;
    int k1 = 0;
    int k2 = 0;
    bool antun = true;
    while(l <= r){
        if(antun){
            antun = false;
            if(s[l] == 'P'){
                l++;
            }else if(s[r] == 'P'){
                r--;
            }else{
                if(s[l+1] == 'P'){
                    r--;
                }else{
                    l++;
                }
                k1++;
                if(k1 == k){
                    cout << "NE";
                    return 0;
                }
            }
        }else{
            antun = true;
            if(s[l] == 'P'){
                l++;
            }else if(s[r] == 'P'){
                r--;
            }else{
                if(s[l+1] == 'P'){
                    r--;
                }else{
                    l++;
                }
                k2++;
                if(k2 == k){
                    cout << "DA";
                    return 0;
                }
            }
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -