Submission #866733

#TimeUsernameProblemLanguageResultExecution timeMemory
866733becaidoKamenčići (COCI21_kamencici)C++17
70 / 70
28 ms174684 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx,popcnt,sse4,abm") #include <bits/stdc++.h> using namespace std; #ifdef WAIMAI #define debug(HEHE...) cout << "[" << #HEHE << "] : ", dout(HEHE) void dout() { cout << "\n"; } template<typename T, typename...U> void dout(T t, U...u) { cout << t << (sizeof...(u) ? ", " : ""), dout(u...); } #else #define debug(...) 7122 #endif #define ll long long #define Waimai ios::sync_with_stdio(false), cin.tie(0) #define FOR(x,a,b) for(int x = a, I = b; x <= I; x++) #define pb emplace_back #define F first #define S second const int SIZE = 355; int n, k; string s; int pre[SIZE]; int dp[SIZE][SIZE][SIZE]; int cal(int l, int r, int cur) { if (dp[l][r][cur] != -1) return dp[l][r][cur]; int cnt = pre[n] - (pre[r] - pre[l - 1]) - cur; if (cur >= k) dp[l][r][cur] = 0; else if (cnt >= k) dp[l][r][cur] = 1; else dp[l][r][cur] = (!cal(l, r - 1, cnt) || !cal(l + 1, r, cnt)); return dp[l][r][cur]; } void solve() { cin >> n >> k; cin >> s, s = " " + s; FOR (i, 1, n) pre[i] = pre[i - 1] + (s[i] == 'C'); FOR (i, 1, n) FOR (j, 1, n) FOR (p, 0, n) dp[i][j][p] = -1; cout << (cal(1, n, 0) ? "DA" : "NE") << '\n'; } int main() { Waimai; solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...