結果

問題 No.2388 At Least K-Characters
ユーザー ああいいああいい
提出日時 2023-07-22 18:37:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 817 ms / 4,000 ms
コード長 902 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 87,172 KB
実行使用メモリ 221,372 KB
最終ジャッジ日時 2023-09-18 13:06:56
合計ジャッジ時間 17,841 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,092 KB
testcase_01 AC 73 ms
71,300 KB
testcase_02 AC 82 ms
76,264 KB
testcase_03 AC 72 ms
71,392 KB
testcase_04 AC 73 ms
71,180 KB
testcase_05 AC 71 ms
71,356 KB
testcase_06 AC 73 ms
71,184 KB
testcase_07 AC 74 ms
71,388 KB
testcase_08 AC 72 ms
71,300 KB
testcase_09 AC 73 ms
71,584 KB
testcase_10 AC 73 ms
71,096 KB
testcase_11 AC 73 ms
71,492 KB
testcase_12 AC 72 ms
71,356 KB
testcase_13 AC 91 ms
76,728 KB
testcase_14 AC 93 ms
76,812 KB
testcase_15 AC 97 ms
77,200 KB
testcase_16 AC 606 ms
221,220 KB
testcase_17 AC 775 ms
221,060 KB
testcase_18 AC 580 ms
221,240 KB
testcase_19 AC 585 ms
221,208 KB
testcase_20 AC 673 ms
221,196 KB
testcase_21 AC 817 ms
221,208 KB
testcase_22 AC 800 ms
221,108 KB
testcase_23 AC 811 ms
221,244 KB
testcase_24 AC 722 ms
221,068 KB
testcase_25 AC 569 ms
221,268 KB
testcase_26 AC 749 ms
221,288 KB
testcase_27 AC 725 ms
220,968 KB
testcase_28 AC 776 ms
221,160 KB
testcase_29 AC 686 ms
221,032 KB
testcase_30 AC 682 ms
221,212 KB
testcase_31 AC 619 ms
221,152 KB
testcase_32 AC 580 ms
221,372 KB
testcase_33 AC 580 ms
221,348 KB
testcase_34 AC 771 ms
221,120 KB
testcase_35 AC 807 ms
221,264 KB
testcase_36 AC 745 ms
221,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M,K = map(int,input().split())
S = input()
now = 0
dat = [0] * 26
P = 998244353

dp = [[0] * 27 for _ in range(M + 1)]

ans = 0
for i in range(N):
    c = ord(S[i]) - ord('a')
    for j in range(c):
        if dat[j] == 0:
            dp[i + 1][now + 1] += 1
        else:
            dp[i + 1][now] += 1
    for j in range(27):
        dp[i + 1][j] += dp[i][j] * j
        if 0 < j < 26:
            dp[i + 1][j + 1] += dp[i][j] * (26 - j)
    for j in range(27):
        dp[i + 1][j] %= P
    if dat[c] == 0:
        now += 1
        dat[c] +=  1
    if now >= K:ans += 1

for i in range(N,M):
    for j in range(1,27):
        dp[i + 1][j] += dp[i][j] * j
        if 0 < j < 26:
            dp[i + 1][j + 1] += dp[i][j] * (26 - j)
    for j in range(27):
        dp[i + 1][j] %= P
    


for i in range(K,27):
    for j in range(M + 1):
        ans += dp[j][i]
if now >= K:ans -= 1
print(ans % P)
0