Submission #1181062

#TimeUsernameProblemLanguageResultExecution timeMemory
1181062Fikrat_AsadzadehKamenčići (COCI21_kamencici)C++20
0 / 70
0 ms324 KiB
#include <bits/stdc++.h> using namespace std; #define ll int #define FORI(i, n) for(ll i = 0; i < n; i++) #define FOR(i, n) for(ll i = 1; i <= n; i++) typedef vector < ll > vl; typedef set < ll > setl; #define ff first #define ss second #define all(v) v.begin(), v.end() #define pll pair<ll, ll> #define db double #define nll cout << "\n" #define nl "\n" #define sync ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); ll poww(ll a, ll b){ ll res = 1; while(b){ if(b & 1)res *= a; a *= a; b >>= 1; } return res; } const ll mod = 998244353; const int sz = 350 + 23 ; const long long imax = LLONG_MAX; ll n, m, k, res, q, x, y; ll a[sz]; string s; ll dp[sz][sz]; ll f(ll l, ll r, ll c1 = 0, ll c2 = 0, bool turn = 1){ if(l > r || c1 == k || l == n || r == 0)return 0; if(c2 == k)return 1; if(~dp[l][r])return dp[l][r]; ll cse = 0; if(turn){ cse |= f(l + 1, r, c1 + ((s[l] == 'C')), c2, !turn); cse |= f(l, r - 1, c1 + (s[r] == 'C'), c2, !turn); } else{ cse = 1; cse &= f(l + 1, r, c1, c2 + (s[l] == 'C'), !turn); cse &= f(l, r - 1, c1, c2 + (s[r] == 'C'), !turn); } return dp[l][r] = cse; } void solve(){ cin >> n >> k; FORI(i, n){ FORI(j, n)dp[i][j] = -1; } cin >> s; s = s; x = f(0, n - 1); cout << (x ? "DA" : "NE"); } //IOI rice hub signed main(){ // freopen("input.txt","r",stdin);a // freopen("output.txt","w",stdout); sync; ll t = 1; // cin >> t; while(t--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...