Submission #1305093

#TimeUsernameProblemLanguageResultExecution timeMemory
1305093muhammad-ahmadKamenčići (COCI21_kamencici)C++20
0 / 70
1 ms720 KiB
// #include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <set>
#include <deque>
#include <numeric>
#include <stack>
#include <chrono>
using namespace std;

void fast_io(){
	// freopen("", "r", stdin);
	// freopen("", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(); cout.tie();
	cout << setprecision(9);
}

#define int long long
#define endl '\n'
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second

const int N = 4e2;

bool dp[N][N][N];

void solve() {
	int n, K; cin >> n >> K;
	string s; cin >> s;
	for (int i = 0; i <= n; i++){
		for (int j = 0; j < K; j++) dp[i][i - 1][j] = 1;
	}
	
	for (int le = 1; le <= n; le++){
		for (int l = 1; l + le - 1 <= n; l++){
			int r = l + le - 1;
			for (int x = 0; x < K; x++){
				if (s[l] == 'C'){
					if (dp[l + 1][r][x + 1] == 0){
						dp[l][r][x] = 1;
					}
				}
				else if (dp[l + 1][r][x] == 0) dp[l][r][x] = 1;
				
				if (s[r] == 'C'){
					if (dp[l][r - 1][x + 1] == 0){
						dp[l][r][x] = 1;
					}
				}
				else if (dp[l][r - 1][x] == 0) dp[l][r][x] = 1;
			}
		}
	}
	cout << (dp[1][n][0] ? "DA" : "NE") << endl;
	return;
}

signed main() {
    fast_io();
    srand(chrono::steady_clock::now().time_since_epoch().count());
    int tc = 1;
    // cin >> tc;
    while (tc--) solve();
    return 0;
}



#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...