제출 #1184259

#제출 시각아이디문제언어결과실행 시간메모리
1184259al95ireyizKamenčići (COCI21_kamencici)C++20
70 / 70
80 ms130632 KiB
//*** Bismillah ***// // It's the evening of another day. And the end of mine... #pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #if !defined(ONLINE_JUDGE) and !defined(EVAL) #include "template/debug.h" #else #define d(x...) #endif #define ll long long const ll INF = 1e9; const ll INFL = 1e18; const ll MOD = 1e9 + 7; const ll maxn = 350 + 5; ll n,m,k=0; bool dp[maxn][maxn][2][maxn], vis[maxn][maxn][2][maxn]; ll a[maxn], ps[maxn]; ll f(ll l, ll r, ll c, ll ct){ if(l > r) return 0; if(vis[l][r][c][ct]) return dp[l][r][c][ct]; vis[l][r][c][ct] = 1; dp[l][r][c][ct] = 0; ll nct = ps[n] - (ps[r] - ps[l-1]) - ct; if(ct + a[l] < m) dp[l][r][c][ct] |= !f(l+1, r, c^1, nct); if(ct + a[r] < m) dp[l][r][c][ct] |= !f(l, r-1, c^1, nct); return dp[l][r][c][ct]; } void _(){ cin>>n>>m; char c; for(ll i=1;i<=n;i++) cin>>c, a[i] = (c == 'C'), ps[i] = ps[i-1] + a[i]; memset(dp, -1, sizeof(dp)); if(f(1, n, 0, 0)) cout<<"DA\n"; else cout<<"NE\n"; } signed main(){ auto testcaseruntime=clock(); cin.tie(0)->sync_with_stdio(0); ll t=1; // cin>>t; while(t--){ _(); } cerr<<"\n\033[1;31mTime: \033[1;30m" <<(double)(clock()-testcaseruntime)/1000000<<"\033[1;32m seconds\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...