# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
655482 | Kamenčići (COCI21_kamencici) | C++17 | 45 ms | 84956 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;
int n,k;
vector<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][cnt1]) return dp[l][r][cnt1];
if (!solve(l+1,r,cnt2,cnt1+(s[l]=='C')) || !solve(l,r-1,cnt2,cnt1+(s[r]=='C'))) return dp[l][r][cnt1] = 1;
return dp[l][r][cnt1] = 0;
}
int main(){
cin.tie(0)->sync_with_stdio(0);
cin >> n >> k >> s;
dp.resize(n,vector<vector<int>>(n,vector<int>(k,-1)));
if (solve(0,n-1,0,0)) cout << "DA";
else 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... |