結果

問題 No.2388 At Least K-Characters
ユーザー Nzt3Nzt3
提出日時 2023-07-22 23:38:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 272 ms / 4,000 ms
コード長 838 bytes
コンパイル時間 2,452 ms
コンパイル使用メモリ 209,256 KB
実行使用メモリ 124,856 KB
最終ジャッジ日時 2023-09-18 13:06:57
合計ジャッジ時間 9,077 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 226 ms
124,624 KB
testcase_17 AC 227 ms
124,668 KB
testcase_18 AC 233 ms
124,608 KB
testcase_19 AC 235 ms
124,632 KB
testcase_20 AC 246 ms
124,684 KB
testcase_21 AC 272 ms
124,676 KB
testcase_22 AC 268 ms
124,852 KB
testcase_23 AC 268 ms
124,668 KB
testcase_24 AC 256 ms
124,780 KB
testcase_25 AC 233 ms
124,736 KB
testcase_26 AC 259 ms
124,656 KB
testcase_27 AC 260 ms
124,676 KB
testcase_28 AC 263 ms
124,640 KB
testcase_29 AC 249 ms
124,704 KB
testcase_30 AC 240 ms
124,856 KB
testcase_31 AC 235 ms
124,796 KB
testcase_32 AC 240 ms
124,852 KB
testcase_33 AC 236 ms
124,668 KB
testcase_34 AC 258 ms
124,664 KB
testcase_35 AC 270 ms
124,664 KB
testcase_36 AC 258 ms
124,604 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<vector<ll>>dp(M+1,vector<ll>(27));
  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