| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1332336 | hauserl | Kamenčići (COCI21_kamencici) | C++20 | 1096 ms | 408 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)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
