Submission #675525

#TimeUsernameProblemLanguageResultExecution timeMemory
675525TangirkulKamenčići (COCI21_kamencici)C++17
70 / 70
45 ms49728 KiB
#include<bits/stdc++.h> #define ll long long #define fi first #define se second #define pb push_back #define sz size #define Junanna ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; const ll K = 32; const ll INF = 1e9 + 7; const ll MOD = 1e9 + 7; const ll N = (1e5 + 125); ll n, k; string s; bool dp[400][400][400], used[400][400][400], p[500]; ll rec (ll l, ll r, ll a, ll b) { if (used[l][r][a]) { return dp[l][r][a]; } if (b == k) { dp[l][r][a] = 1; return 1; } if (a == k) { dp[l][r][a] = 0; return 0; } used[l][r][a] = 1; if ((n - (r - l + 1)) % 2 == 1) { dp[l][r][a] = min (rec (l + 1, r, a, b + (s[l] == 'C')), rec (l, r - 1, a, b + (s[r] == 'C'))); return dp[l][r][a]; } else { dp[l][r][a] = max (rec (l + 1, r, a + (s[l] == 'C'), b), rec (l, r - 1, a + (s[r] == 'C'), b)); return dp[l][r][a]; } } void ma1n () { cin >> n >> k; cin >> s; for (ll i = 0; i < n; i++) { p[i] = p[i - 1] + (s[i] == 'C'); } if (rec (0, n - 1, 0, 0)) { cout << "DA"; } else { cout << "NE"; } } int main () { Junanna; ll t = 1; while (t--) { ma1n (); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...