Submission #1330368

#TimeUsernameProblemLanguageResultExecution timeMemory
1330368vuqar_bazarov1Kamenčići (COCI21_kamencici)C++20
10 / 70
1092 ms344 KiB
/*
* * author: attacker
* * created: 01.03.2026 14:30:19
*/
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

#define mt_rng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, k;
  string s;
  cin >> n >> k >> s;
  auto Solve = [&](auto&& self, int l, int r, int cc_1, int cc_2, bool which) -> bool {
    if (cc_1 == k) {
      return false;
    }
    if (cc_2 == k) {
      return true;
    }
    if (l > r) {
      return false;
    }
    if (which) {
      bool low = self(self, l + 1, r, cc_1 + (s[l] == 'C'), cc_2, !which);
      bool high = self(self, l, r - 1, cc_1 + (s[r] == 'C'), cc_2, !which);
      return low || high;
    } else {
      bool low = self(self, l + 1, r, cc_1, cc_2 + (s[l] == 'C'), !which);
      bool high = self(self, l, r - 1, cc_1, cc_2 + (s[r] == 'C'), !which);
      return low && high;
    }
  };
  cout << (Solve(Solve, 0, n - 1, 0, 0, true) ? "DA" : "NE") << '\n';
  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...