Submission #862208

# Submission time Handle Problem Language Result Execution time Memory
862208 2023-10-17T17:22:11 Z Mizo_Compiler Kamenčići (COCI21_kamencici) C++14
0 / 70
91 ms 337000 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;
#define pb push_back
#define sz(x) int(x.size())
#define all(x) x.begin(),x.end()
#define F first
#define S second
const int N = 350;
int n, dp[N][N][N+1][2], k, p[N], s[N];
string st;

int sol(int l, int r, int rem, bool t) {
	if (rem == 0)return 0;
	if (p[l]+s[r]-(k-rem) == 0)return 1;
	int &ret = dp[l][r][rem][t];
	if (~ret)return ret;
	if (!t) {
		if (sol(l+1, r, rem - (!t && st[l]=='C'), !t) == 1)return ret = 1;
		if (sol(l, r-1, rem - (!t && st[r]=='C'), !t) == 1)return ret = 1;
		return ret = 0;
	} else {
		if (sol(l+1, r, rem - (!t && st[l]=='C'), !t) == 0)return ret = 0;
		if (sol(l, r-1, rem - (!t && st[r]=='C'), !t) == 0)return ret = 0;
		return ret = 1;
	}
}

int main () {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n >> k >> st;
	p[0] = 0;
	for (int i = 1; i < n; i++) {
		p[i] = (p[i-1] + (st[i-1] == 'C'));
	}
	s[n-1] = 0;
	for (int i = n-2; i >= 0; i--) {
		s[i] = (s[i+1] + (st[i+1] == 'C'));
	}
	memset(dp, -1, sizeof dp);
	cout << (sol(0, n-1, k, 0) ? "DA" : "NE");
}
# Verdict Execution time Memory Grader output
1 Incorrect 91 ms 337000 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 91 ms 337000 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 91 ms 337000 KB Output isn't correct
2 Halted 0 ms 0 KB -