Submission #1332336

#TimeUsernameProblemLanguageResultExecution timeMemory
1332336hauserlKamenčići (COCI21_kamencici)C++20
10 / 70
1096 ms408 KiB
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int k;
int n;
string pebbles;

bool f(int l, int r, int currK, int currOpK, bool isOpponent) { // bool loose
    if (currK >= k) return true;
    if (currOpK >= k) return false;

    if (l + 1 >= r) return false;
    if (l < 0 || r > n) return false;

    if (isOpponent) {
        auto p1 = f(l+1, r, currK, currOpK + (pebbles[l] == 'C'), false);
        auto p2 = f(l, r-1, currK, currOpK + (pebbles[r-1] == 'C'), false);

        return p1 || p2;

    } else {
        auto p1 = f(l+1, r, currK + (pebbles[l] == 'C'), currOpK, true);
        auto p2 = f(l, r-1, currK + (pebbles[r-1] == 'C'), currOpK, true);

        return p1 && p2;
    }
}

int main() {
    
    scanf("%d %d", &n, &k);

    cin >> pebbles;

    auto res = f(0, n, 0, 0, false);

    if (res) {
        cout << "NE";
    } else {
        cout << "DA";
    }

    return 0;
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:32:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...