Submission #869539

#TimeUsernameProblemLanguageResultExecution timeMemory
869539JoksimKaktusKamenčići (COCI21_kamencici)C++17
70 / 70
38 ms183124 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int dp [360][360][360]; int pre[360]; int n,k; string s; bool find(int l,int r,int m){ if(dp[l][r][m] != -1)return dp[l][r][m]; int h = pre[n] - m - (pre[r]-pre[l-1]); if(m >= k){ return dp[l][r][m] = false; }else if(h >= k){ return dp[l][r][m] = true; }else{ return dp[l][r][m] = !find(l+1,r,h) || !find(l,r-1,h); } } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0); cin >> n >> k >> s; pre[0]=0; s = " " + s; for(int i = 1;i <= n;i++){ pre[i]=pre[i-1] + (s[i] == 'C'); } memset(dp,-1,sizeof dp); bool da = find(1,n,0); da ? cout << "DA" : cout << "NE"; return 0; }

Compilation message (stderr)

Main.cpp: In function 'bool find(int, int, int)':
Main.cpp:15:28: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   15 |         return dp[l][r][m] = false;
      |                ~~~~~~~~~~~~^~~~~~~
Main.cpp:17:28: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   17 |         return dp[l][r][m] = true;
      |                ~~~~~~~~~~~~^~~~~~
Main.cpp:19:28: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   19 |         return dp[l][r][m] = !find(l+1,r,h) || !find(l,r-1,h);
      |                ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...