結果

問題 No.2388 At Least K-Characters
ユーザー Nzt3Nzt3
提出日時 2023-07-22 23:41:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 232 ms / 4,000 ms
コード長 917 bytes
コンパイル時間 2,248 ms
コンパイル使用メモリ 208,552 KB
実行使用メモリ 109,396 KB
最終ジャッジ日時 2023-09-18 13:07:04
合計ジャッジ時間 7,918 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 182 ms
109,180 KB
testcase_17 AC 156 ms
109,240 KB
testcase_18 AC 189 ms
109,132 KB
testcase_19 AC 191 ms
109,080 KB
testcase_20 AC 204 ms
109,168 KB
testcase_21 AC 230 ms
109,124 KB
testcase_22 AC 229 ms
109,216 KB
testcase_23 AC 227 ms
109,164 KB
testcase_24 AC 214 ms
109,396 KB
testcase_25 AC 191 ms
109,168 KB
testcase_26 AC 221 ms
109,232 KB
testcase_27 AC 216 ms
109,252 KB
testcase_28 AC 224 ms
109,152 KB
testcase_29 AC 207 ms
109,332 KB
testcase_30 AC 204 ms
109,188 KB
testcase_31 AC 194 ms
109,272 KB
testcase_32 AC 191 ms
109,216 KB
testcase_33 AC 189 ms
109,148 KB
testcase_34 AC 218 ms
109,100 KB
testcase_35 AC 232 ms
109,176 KB
testcase_36 AC 216 ms
109,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr int mod=998244353;
void ch(ll &a,ll b){
  a=(a+b)%mod;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,M,K;
  cin>>N>>M>>K;
  string S;
  cin>>S;
  vector<array<ll,27>>dp(M+1,array<ll,27>());
  for(int i=0;i<=M;i++){
    for(int j=0;j<=26;j++)dp[i][j]=0;
  }
  unordered_set<char>sd;

  ll ans=0;
  for(int i=0;i<M;i++){
    for(int j=0;j<=26;j++){
      ch(dp[i+1][j],dp[i][j]*j);
    }
    for(int j=0;j<26;j++){
      ch(dp[i+1][j+1],dp[i][j]*(26-j));
    }
    if(i<N){
      for(int j='a';j<S[i];j++){
        if(sd.find(j)==sd.end()){
          ch(dp[i+1][sd.size()+1],1);
        }else{
          ch(dp[i+1][sd.size()],1);
        }
      }
      if(sd.size()>=K)++ans;
      sd.insert(S[i]);
    }
  }
  for(int i=0;i<=M;i++){
    for(int j=K;j<=26;j++){
      ch(ans,dp[i][j]);
    }
  }
  cout<<ans<<'\n';
}
0