結果

問題 No.2388 At Least K-Characters
ユーザー sotanishysotanishy
提出日時 2023-07-21 23:45:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 782 ms / 4,000 ms
コード長 607 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 86,852 KB
実行使用メモリ 221,332 KB
最終ジャッジ日時 2023-09-18 13:03:49
合計ジャッジ時間 17,243 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,240 KB
testcase_01 AC 74 ms
71,120 KB
testcase_02 AC 81 ms
76,004 KB
testcase_03 AC 75 ms
71,216 KB
testcase_04 AC 75 ms
71,116 KB
testcase_05 AC 78 ms
71,116 KB
testcase_06 AC 74 ms
71,280 KB
testcase_07 AC 75 ms
71,296 KB
testcase_08 AC 74 ms
70,980 KB
testcase_09 AC 74 ms
71,124 KB
testcase_10 AC 75 ms
71,144 KB
testcase_11 AC 76 ms
71,280 KB
testcase_12 AC 73 ms
71,120 KB
testcase_13 AC 94 ms
76,716 KB
testcase_14 AC 94 ms
76,612 KB
testcase_15 AC 96 ms
76,624 KB
testcase_16 AC 612 ms
221,332 KB
testcase_17 AC 725 ms
220,948 KB
testcase_18 AC 588 ms
221,024 KB
testcase_19 AC 589 ms
221,116 KB
testcase_20 AC 625 ms
220,880 KB
testcase_21 AC 701 ms
221,168 KB
testcase_22 AC 727 ms
221,048 KB
testcase_23 AC 698 ms
221,104 KB
testcase_24 AC 782 ms
220,948 KB
testcase_25 AC 591 ms
220,944 KB
testcase_26 AC 710 ms
220,988 KB
testcase_27 AC 665 ms
221,068 KB
testcase_28 AC 688 ms
220,996 KB
testcase_29 AC 717 ms
220,932 KB
testcase_30 AC 707 ms
221,112 KB
testcase_31 AC 602 ms
220,952 KB
testcase_32 AC 592 ms
221,060 KB
testcase_33 AC 589 ms
221,100 KB
testcase_34 AC 664 ms
220,936 KB
testcase_35 AC 700 ms
221,096 KB
testcase_36 AC 658 ms
220,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0