# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
869539 | JoksimKaktus | Kamenčići (COCI21_kamencici) | C++17 | 38 ms | 183124 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |