Submission #844064

# Submission time Handle Problem Language Result Execution time Memory
844064 2023-09-05T05:41:28 Z RealPanda Kamenčići (COCI21_kamencici) C++17
70 / 70
1 ms 600 KB
#include <bits/stdc++.h>
using namespace std;
int n, k;

int main () {
    cin >> n >> k;
    int c[2];
    c[0] = c[1] = k;
    string s;
    cin >> s;
    int l = 0, r = n-1;
    int turn = 0;
    while(l <= r && c[0] > 0 && c[1] > 0) {
        if(s[l] == 'P') {
            l++;
        }
        else if(s[r] == 'P') {
            r--;
        }
        else {
            c[turn]--;
            int t1, t2;
            t1 = t2 = 0;
            while(s[l + t1] != 'P' && (l+t1) < n-1) {
                t1++;
            }
            while(s[r-t2]!= 'P' && (r-t2) > 0) {
                t2++;
            }
            if(t1 >= t2) {
                l++;
            }
            else {
                r--;
            }

        }
        turn ^=1;
    }
    if(c[0] > 0) {
        cout << "DA" << endl;
    }
    else {
        cout << "NE" << endl;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 556 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 600 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 556 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 600 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct