# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
862214 | TAhmed33 | Kamenčići (COCI21_kamencici) | C++98 | 58 ms | 169900 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int dp[351][351][351];
int arr[351];
int n, k;
int ans (int l, int r, int c, int c2) {
if (c == k || c2 == k) return 1;
int &ret = dp[l][r][c];
if (ret != -1) return ret;
int x = r - l + 1; ret = 0;
if ((x & 1) == (n & 1)) {
ret |= !ans(l + 1, r, c + arr[l], c2);
ret |= !ans(l, r - 1, c + arr[r], c2);
} else {
ret |= !ans(l + 1, r, c, c2 + arr[l]);
ret |= !ans(l, r - 1, c, c2 + arr[r]);
}
return ret;
}
int main () {
memset(dp, -1, sizeof(dp));
cin >> n >> k;
for (int i = 1; i <= n; i++) {
char x; cin >> x; arr[i] = (x == 'C');
}
cout << (ans(1, n, 0, 0) ? "DA\n" : "NE\n");
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |