# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
717234 | Juan | Kamenčići (COCI21_kamencici) | C++14 | 1087 ms | 3008 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;
#define int long long
#define pii pair<int, int>
#define ff first
#define ss second
const int maxn = 55;
bool v[maxn];
int dp[maxn][maxn][maxn][maxn][3];
bool solve(int l, int r, int k1, int k2, int p){
if(k1==0) return 0;
if(k2==0) return 1;
if(dp[l][r][k1][k2][p]) return dp[l][r][k1][k2][p];
if(p==1){
return dp[l][r][k1][k2][p] = max(solve(l+1, r, k1-v[l], k2, 2), solve(l, r-1, k1-v[r], k2, 2));
}
else{
return dp[l][r][k1][k2][p] = min(solve(l+1, r, k1, k2-v[l], 1), solve(l, r-1, k1, k2-v[r], 1));
}
}
int32_t main(){
int n, k; cin >> n >> k;
for(int i = 0; i < n; i++){
char c; cin >> c;
if(c=='C') v[i] = 1;
}
if(solve(0, n-1, k, k, 1)) cout << "DA\n";
else cout << "NE\n";
}
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... |