結果
| 問題 | No.2388 At Least K-Characters |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-22 23:38:51 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 198 ms / 4,000 ms |
| コード長 | 838 bytes |
| 記録 | |
| コンパイル時間 | 1,364 ms |
| コンパイル使用メモリ | 220,272 KB |
| 実行使用メモリ | 124,912 KB |
| 最終ジャッジ日時 | 2026-07-01 21:06:31 |
| 合計ジャッジ時間 | 6,260 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 |
ソースコード
#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';
}