제출 #1330308

#제출 시각아이디문제언어결과실행 시간메모리
1330308vuqar_bazarov1Kamenčići (COCI21_kamencici)C++20
0 / 70
1 ms344 KiB
/*
* * author: attacker
* * created: 01.03.2026 11:38:36
*/
#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;
  bool fail = false;
  auto Solve = [&](auto&& self, int low, int high, int cc_1, int cc_2, bool which) {
    if (high < low) {
      return;
    }
    if (cc_1 == k) {
      fail = true;
      return;
    }
    if (which) {
      if (s[low] == s[high]) {
        self(self, low + 1, high, cc_1 += (s[low] == 'C'), cc_2, !which);
        self(self, low, high - 1, cc_1 += (s[high] == 'C'), cc_2, !which);
      } else if (s[low] == 'C') {
        self(self, low, high - 1, cc_1 += (s[high] == 'C'), cc_2, !which);
      } else {
        self(self, low + 1, high, cc_1 += (s[low] == 'C'), cc_2, !which);
      }
    } else {
      self(self, low + 1, high, cc_1, cc_2 += (s[low] == 'C'), !which);
      self(self, low, high - 1, cc_1, cc_2 += (s[high] == 'C'), !which);
    }
    return;
  };
  Solve(Solve, 0, n - 1, 0, 0, true);
  cout << (fail ? "NE" : "DA") << '\n';
  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...