| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 515807 | aris12345678 | Kamenčići (COCI21_kamencici) | C++14 | 1 ms | 292 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    string s;
    cin >> s;
    int l = 0, r = n-1, turn = 0, x = 1;
    vector<int> sum(2, 0);
    while(l <= r) {
        // cout << l << " " << r << " ";
        if(s[l] == 'P')
            l++;
        else if(s[r] == 'P')
            r--;
        else if(l+1 <= r && s[l+1] == 'C')
            l++, sum[turn]++;
        else if(l <= r-1 && s[r-1] == 'C')
            r--, sum[turn]++;
        else
            l++, sum[turn]++;
        // cout << turn << " " << sum[turn] << "\n";
        if(sum[turn] == k) {
            if(turn == 0)
                printf("NE\n");
            else
                printf("DA\n");
            break;
        }
        turn ^= x;
    }
    return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
