답안 #874562

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
874562 2023-11-17T09:39:28 Z ngjabach Kamenčići (COCI21_kamencici) C++14
0 / 70
61 ms 175456 KB
// NgJaBach: Forever Meadow <3

#include<bits/stdc++.h>

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long int ll;
typedef unsigned long long ull;
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define bend(a) a.begin(),a.end()
#define rev(x) reverse(bend(x))
#define mset(a) memset(a, 0, sizeof(a))
#define fi first
#define se second
#define gcd __gcd
#define getl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
#define endl '\n'
const int N=355,M=1000000007;
const ll INF=1e18+7;
int dp[N][N][N],pref[N],n,k;
string s;
int can_win(int L,int R,int reds){
    int &res=dp[L][R][reds];
    if(res!=-1) return res;
    if(reds>=k) return res=0;
    int other_reds=pref[n]-pref[R]+pref[L-1]-reds;
    if(other_reds>=k) return res=1;
    if(can_win(L+1,R,other_reds) or can_win(L,R-1,other_reds)) return res=1;
    return res=0;
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
//    freopen(".inp","r",stdin);
//    freopen(".out","w",stdout);
    cin>>n>>k;
    cin>>s; s="$"+s;
    pref[0]=0;
    for(int i=1;i<=n;++i) pref[i]=pref[i-1]+(s[i]=='C');
    memset(dp,-1,sizeof dp);
    if(can_win(1,n,(s[n]=='C'))) cout<<"DA";
    else cout<<"NE";
    return 0;
}
/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/
# 결과 실행 시간 메모리 Grader output
1 Incorrect 61 ms 175456 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 61 ms 175456 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 61 ms 175456 KB Output isn't correct
2 Halted 0 ms 0 KB -