이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define ctoi(x) int(x-'0')
#define cdv(x,y) (((x)+(y)-1)/(y))
#define LOOP(n) for(int rp=0;rp<(n);rp++)
#define sz(x) int(x.size())
#define dbg(x) cout << (#x) << " : " << x << endl;
#define sq(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef long double dl;
const int SZ=2e5+7;
bool dp[350][350][350],vs[350][350][350];
int n,k,p[350],a[350]{};
bool solve(int l,int r,int c){
if(c==k)return 0;
int C=(l>0?p[l-1]:0)+p[n-1]-p[r];
if(C-c==k)return 1;
if(vs[l][r][c])return dp[l][r][c];
vs[l][r][c]=1;
return dp[l][r][c]=!(solve(l+1,r,C-c)&solve(l,r-1,C-c));
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int tt=1;
//cin >> tt;
LOOP(tt){
cin >> n >> k;
for(int i=0;i<n;i++){
char c;cin >> c;
p[i]=(i>0?p[i-1]:0);
if(c=='C')p[i]++,a[i]=1;
}
cout << (solve(0,n-1,0)?"DA":"NE");
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |