Submission #715026

# Submission time Handle Problem Language Result Execution time Memory
715026 2023-03-25T20:49:48 Z keystone Kamenčići (COCI21_kamencici) C++14
0 / 70
1 ms 212 KB
#include <iostream>
#include <string>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;

    string pebbles;
    cin >> pebbles;

    int redCount = 0;
    for (char c : pebbles) {
        if (c == 'C') {
            redCount++;
        }
    }

    bool antunWins = true;
    if (redCount <= k) {
        antunWins = false;
    } else {
        int redRemoved = 0;
        int blueRemoved = 0;
        int i = 0;
        int j = n-1;
        while (i < j) {
            if (pebbles[i] == 'C') {
                redRemoved++;
                if (redRemoved == k) {
                    antunWins = false;
                    break;
                }
            } else {
                blueRemoved++;
            }
            i++;

            if (pebbles[j] == 'C') {
                redRemoved++;
                if (redRemoved == k) {
                    antunWins = false;
                    break;
                }
            } else {
                blueRemoved++;
            }
            j--;
        }
        if (i == j && pebbles[i] == 'C' && redRemoved < k) {
            antunWins = false;
        }
    }

    if (antunWins=true) {
        cout << "DA" << endl;
    } else {
        cout << "NE" << endl;
    }

    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:56:18: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   56 |     if (antunWins=true) {
      |         ~~~~~~~~~^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -