結果

問題 No.2388 At Least K-Characters
ユーザー nemutainemutai
提出日時 2023-07-21 23:02:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,834 bytes
コンパイル時間 2,462 ms
コンパイル使用メモリ 210,956 KB
実行使用メモリ 296,752 KB
最終ジャッジ日時 2023-09-18 12:59:41
合計ジャッジ時間 49,637 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define all(v) v.begin(),v.end()
using ll = long long;
using ull = unsigned long long;
using vll=vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,ll>;
using vp=vector<pair<ll, ll>>;

const ll INF=1ll<<60;
ll mod10=1e9+7;
ll mod99=998244353;
const double PI = acos(-1);

#define rep(i,n) for (ll i=0;i<n;++i)
#define per(i,n) for(ll i=n-1;i>=0;--i)
#define rep2(i,a,n) for (ll i=a;i<n;++i)
#define per2(i,a,n) for (ll i=a;i>=n;--i)

template <typename T>
bool chmax(T &a,const T& b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a,const T& b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}

int main(){
    ll N,M,K;
    cin>>N>>M>>K;
    string S;
    cin>>S;
    vector<vvll> dp(M+1,vvll(2,vll(30)));
    dp[0][0][0]=1;
    set<int> st;
    rep(i,M){
        rep(k,27){
            if(i<N){
                if(st.count(S[i]))dp[i+1][0][k]+=dp[i][0][k];
                else dp[i+1][0][k+1]+=dp[i][0][k];
                dp[i+1][1][k+1]+=dp[i][1][k]*(26-k);
                dp[i+1][1][k]+=dp[i][1][k]*k;
                ll cnt0=0,cnt1=0;
                rep(s,S[i]-'a'){
                    if(st.count(s+'a'))cnt1++;
                    else cnt0++;
                }
                dp[i+1][1][k+1]+=dp[i][0][k]*cnt0;
                dp[i+1][1][k]+=dp[i][0][k]*cnt1;
            }else{
                dp[i+1][1][k+1]+=dp[i][1][k]*(26-k);
                dp[i+1][1][k]+=dp[i][1][k]*k;
            }
            dp[i+1][1][k]%=mod99;
            dp[i+1][1][k+1]%=mod99;
            dp[i+1][0][k]%=mod99;
            dp[i+1][0][k+1]%=mod99;
        }
        st.insert(S[i]);
    }
    ll ans=0;
    rep(i,M+1) rep2(k,K,27) ans=(ans+dp[i][1][k])%mod99;
    cout << ans+2 << endl;

}
0