結果
| 問題 |
No.2388 At Least K-Characters
|
| コンテスト | |
| ユーザー |
sotanishy
|
| 提出日時 | 2023-07-21 23:45:03 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 726 ms / 4,000 ms |
| コード長 | 607 bytes |
| コンパイル時間 | 178 ms |
| コンパイル使用メモリ | 82,012 KB |
| 実行使用メモリ | 220,128 KB |
| 最終ジャッジ日時 | 2024-07-05 04:09:12 |
| 合計ジャッジ時間 | 14,624 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 |
ソースコード
import sys
input = sys.stdin.readline
mod = 998244353
N, M, K = map(int, input().split())
S = input().rstrip()
dp = [[0] * 27 for _ in range(M+1)]
ch = set()
ans = 0
for i in range(M):
for j in range(1, 27):
dp[i+1][j] = (dp[i][j-1] * (27 - j) + dp[i][j] * j) % mod
if i < N:
if len(ch) >= K:
ans += 1
for c in range(ord(S[i]) - ord('a')):
k = len(ch)
if c not in ch:
k += 1
dp[i+1][k] += 1
ch.add(ord(S[i]) - ord('a'))
ans += sum(dp[i][j] for i in range(1, M+1) for j in range(K, 27))
print(ans % mod)
sotanishy