이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const int N=355;
int n,k,dp[N][N][N],pre[N];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
memset(dp, -1, sizeof dp);
cin>>n>>k;
string str;
cin>>str;
str=str;
for(int i=1;i<=n;i++)pre[i]=pre[i-1]+(str[i-1]=='C');
for(int l=n;l>=1;l--){
for(int r=l;r<=n;r++){
for(int cnt=0;cnt<=n;cnt++){
if(cnt>=k){
dp[l][r][cnt]=0;
continue;
}
int cnt2=pre[n]-cnt-(pre[r]-pre[l-1]);
if(cnt2>=k)dp[l][r][cnt]=1;
else dp[l][r][cnt]=(!dp[l+1][r][cnt2])||(!dp[l][r-1][cnt2]);
}
}
}
cout<<(dp[1][n][0]?"DA\n":"NE\n");
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... |