結果

問題 No.2388 At Least K-Characters
ユーザー 👑 seekworserseekworser
提出日時 2023-07-17 22:59:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 338 ms / 4,000 ms
コード長 976 bytes
コンパイル時間 306 ms
コンパイル使用メモリ 86,896 KB
実行使用メモリ 81,892 KB
最終ジャッジ日時 2023-09-18 12:51:19
合計ジャッジ時間 9,902 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,136 KB
testcase_01 AC 72 ms
71,408 KB
testcase_02 AC 81 ms
76,060 KB
testcase_03 AC 72 ms
71,208 KB
testcase_04 AC 73 ms
71,016 KB
testcase_05 AC 72 ms
71,256 KB
testcase_06 AC 72 ms
70,968 KB
testcase_07 AC 72 ms
71,196 KB
testcase_08 AC 74 ms
70,996 KB
testcase_09 AC 75 ms
71,264 KB
testcase_10 AC 73 ms
71,240 KB
testcase_11 AC 74 ms
71,400 KB
testcase_12 AC 73 ms
71,328 KB
testcase_13 AC 94 ms
76,632 KB
testcase_14 AC 94 ms
76,744 KB
testcase_15 AC 97 ms
76,596 KB
testcase_16 AC 311 ms
81,480 KB
testcase_17 AC 313 ms
81,680 KB
testcase_18 AC 313 ms
81,564 KB
testcase_19 AC 304 ms
81,816 KB
testcase_20 AC 318 ms
81,508 KB
testcase_21 AC 337 ms
81,648 KB
testcase_22 AC 335 ms
81,616 KB
testcase_23 AC 338 ms
81,736 KB
testcase_24 AC 328 ms
81,892 KB
testcase_25 AC 305 ms
81,712 KB
testcase_26 AC 335 ms
81,504 KB
testcase_27 AC 329 ms
81,468 KB
testcase_28 AC 338 ms
81,700 KB
testcase_29 AC 324 ms
81,508 KB
testcase_30 AC 319 ms
81,500 KB
testcase_31 AC 314 ms
81,612 KB
testcase_32 AC 311 ms
81,620 KB
testcase_33 AC 306 ms
81,764 KB
testcase_34 AC 331 ms
81,448 KB
testcase_35 AC 337 ms
81,540 KB
testcase_36 AC 329 ms
81,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m,k = map(int,input().split())
s = [ord(si) - ord('a') for si in input()]

seen = [False] * 27
dp = [0] * 27
dp[0] = 1
used = 0
ans = 0

for i in range(m):
    dpn = [0] * 27
    for j in range(27):
        dpj = dp[j]
        if i < n and j == used:
            u = 0
            for l in range(s[i]):
                if seen[l]:
                    u += 1
            dpn[j] += u
            if j+1 <= 26:
                dpn[j+1] += s[i] - u
            if seen[s[i]]:
                dpn[j] += 1
            else:
                dpn[j+1] += 1
            dpj -= 1
        if i == n and j == used:
            dpj -= 1
        dpn[j] += dpj * j
        if j + 1 <= 26:
            dpn[j+1] += dpj * (26 - j)
    for j in range(27):
        dpn[j] %= 998244353
    dp = dpn
    if i < n and not seen[s[i]]:
        used += 1
        seen[s[i]] = True
    for j in range(k, 27):
        ans += dp[j]
    ans %= 998244353

if used >= k:
    ans -= 1
print(ans % 998244353)
0