Submission #655475

#TimeUsernameProblemLanguageResultExecution timeMemory
655475googleKamenčići (COCI21_kamencici)C++17
0 / 70
1 ms324 KiB
#include<bits/stdc++.h> using namespace std; int n,k; vector<vector<int>> dp; string s; bool solve(int l, int r, int cnt1,int cnt2){ if (cnt1 >= k) return 0; if (cnt2 >= k) return 1; if (~dp[l][r]) return dp[l][r]; if (!solve(l+1,r,cnt2,cnt1+(s[l]=='C')) || !solve(l,r-1,cnt2,cnt1+(s[r]=='C'))) return dp[l][r] = 1; return dp[l][r] = 0; } int main(){ cin.tie(0)->sync_with_stdio(0); cin >> n >> k >> s; dp.resize(n,vector<int>(n,-1)); if (solve(0,n-1,0,0)) cout << "DA"; else cout << "NE"; return 0; }

Compilation message (stderr)

Main.cpp: In function 'bool solve(int, int, int, int)':
Main.cpp:10:101: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   10 |     if (!solve(l+1,r,cnt2,cnt1+(s[l]=='C')) || !solve(l,r-1,cnt2,cnt1+(s[r]=='C'))) return dp[l][r] = 1;
Main.cpp:11:21: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   11 |     return dp[l][r] = 0;
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...