Submission #1330298

#TimeUsernameProblemLanguageResultExecution timeMemory
1330298vuqar_bazarov1Kamenčići (COCI21_kamencici)C++20
0 / 70
0 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;
  deque<char> dq(s.begin(), s.end());
  bool which = false;
  int cc_1 = 0, cc_2 = 0;
  while (!dq.empty() && max(cc_1, cc_2) < k) {
    which = !which;
    if (which) {
      if (dq[0] == 'P') {
        dq.pop_front();
      } else if (dq[int(dq.size() - 1)] == 'P') {
        dq.pop_front();
      } else {
        dq.pop_front();
        cc_1++;
      }
    } else {
      if (dq[0] == 'P') {
        dq.pop_front();
      } else if (dq[int(dq.size() - 1)] == 'P') {
        dq.pop_front();
      } else {
        dq.pop_front();
        cc_2++;
      }
    }
  }
  cout << (max(cc_1, cc_2) == cc_2 ? "DA" : "NE") << '\n';
  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...