結果

問題 No.1740 Alone 'a'
ユーザー 👑 H20H20
提出日時 2021-11-12 22:40:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,204 ms / 2,000 ms
コード長 635 bytes
コンパイル時間 214 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 134,996 KB
最終ジャッジ日時 2024-05-04 10:11:39
合計ジャッジ時間 19,717 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
52,224 KB
testcase_01 AC 35 ms
52,480 KB
testcase_02 AC 36 ms
52,992 KB
testcase_03 AC 1,204 ms
134,656 KB
testcase_04 AC 1,191 ms
134,996 KB
testcase_05 AC 104 ms
78,464 KB
testcase_06 AC 94 ms
77,996 KB
testcase_07 AC 58 ms
70,784 KB
testcase_08 AC 37 ms
58,496 KB
testcase_09 AC 32 ms
51,968 KB
testcase_10 AC 33 ms
52,096 KB
testcase_11 AC 226 ms
87,040 KB
testcase_12 AC 782 ms
123,392 KB
testcase_13 AC 795 ms
121,216 KB
testcase_14 AC 966 ms
131,840 KB
testcase_15 AC 71 ms
76,544 KB
testcase_16 AC 752 ms
118,528 KB
testcase_17 AC 72 ms
76,800 KB
testcase_18 AC 173 ms
83,584 KB
testcase_19 AC 781 ms
123,648 KB
testcase_20 AC 432 ms
100,992 KB
testcase_21 AC 616 ms
109,696 KB
testcase_22 AC 712 ms
116,736 KB
testcase_23 AC 764 ms
116,608 KB
testcase_24 AC 458 ms
101,248 KB
testcase_25 AC 506 ms
101,376 KB
testcase_26 AC 596 ms
109,312 KB
testcase_27 AC 603 ms
111,360 KB
testcase_28 AC 566 ms
105,600 KB
testcase_29 AC 918 ms
132,096 KB
testcase_30 AC 626 ms
110,848 KB
testcase_31 AC 713 ms
117,760 KB
testcase_32 AC 528 ms
106,044 KB
testcase_33 AC 795 ms
117,248 KB
testcase_34 AC 204 ms
84,864 KB
testcase_35 AC 534 ms
104,448 KB
testcase_36 AC 460 ms
99,712 KB
testcase_37 AC 218 ms
85,248 KB
testcase_38 AC 425 ms
95,912 KB
testcase_39 AC 119 ms
79,488 KB
testcase_40 AC 253 ms
89,044 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import product

def count():
    n = int(input())
    a = input()
    mod = 998244353
    #配列は末から
    dp=[[[0] * 3 for k in range(2)] for l in range(n+1)]
    dp[0][0][0] = 1

    #条件に合わせてDP
    for i, less, cnta in product(range(n), (0,1), range(3)):
        max_d = 25 if less else int(ord(a[i])-97)
        for d in range(max_d+1):
            less_ = less or d < max_d
            cnta_ = min(2, cnta + int(d==0))
            dp[i + 1][less_][cnta_] = (dp[i][less][cnta]+dp[i + 1][less_][cnta_])%mod
    
    #合致するものを合算
    ret = dp[n][1][1]
    return ret

print(count())
0