이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define fastIO cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false);
#define mid ((l + r) / 2)
#define lChild ((index * 2) + 1)
#define rChild ((index * 2) + 2)
using namespace std;
struct node {
ll t, a, b;
};
ll dp[351][351][200];
bool get(string& s, ll l, ll r, ll k, vector<ll>& score, bool round) {
/* cout<<round + 1<< " => "<<l<<" "<<r<<endl;
cout<<"Score: "<<score[0]<<" "<<score[1]<<endl;*/
if(score[0] == k) return false;
else if(score[1] == k) return true;
if(dp[l][r][score[0]] != -1) return dp[l][r][score[0]];
bool ans = round;
score[round] += s[l] == 'C';
if(!round) ans |= get(s, l + 1, r, k, score, !round);
else ans &= get(s, l + 1, r, k, score, !round);
score[round] -= s[l] == 'C';
score[round] += s[r] == 'C';
if(!round) ans |= get(s, l, r - 1, k, score, !round);
else ans &= get(s, l, r - 1, k, score, !round);
score[round] -= s[r] == 'C';
return dp[l][r][score[0]] = ans;
}
void solve(ll _) {
ll n, k; cin>>n>>k;
memset(dp, -1, sizeof dp);
string s; cin>>s;
vector<ll> scores = {0, 0};
cout<<(get(s, 0, n - 1, k, scores, 0) ? "DA" : "NE")<<endl;
}
int main() {
fastIO
//freopen("file.in", "r", stdin);
//freopen("file.out", "w", stdout);
ll t = 0; solve(t);
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'bool get(std::string&, long long int, long long int, long long int, std::vector<long long int>&, bool)':
Main.cpp:41:31: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
41 | return dp[l][r][score[0]] = ans;
| ~~~~~~~~~~~~~~~~~~~^~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |