Submission #515807

# Submission time Handle Problem Language Result Execution time Memory
515807 2022-01-19T18:43:21 Z aris12345678 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;
    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

Main.cpp: In function 'int main()':
Main.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 288 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 1 ms 204 KB Output is correct
2 Correct 0 ms 288 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 288 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 288 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 288 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 288 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 288 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 292 KB Output is correct
13 Correct 1 ms 288 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 288 KB Output is correct
16 Correct 0 ms 288 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct