結果
| 問題 |
No.2388 At Least K-Characters
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-22 23:41:46 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 267 ms / 4,000 ms |
| コード長 | 917 bytes |
| コンパイル時間 | 2,057 ms |
| コンパイル使用メモリ | 203,048 KB |
| 最終ジャッジ日時 | 2025-02-15 18:16:09 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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<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';
}