結果

問題 No.1740 Alone 'a'
ユーザー 👑 H20H20
提出日時 2021-11-12 22:40:54
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 1,475 ms / 2,000 ms
コード長 635 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 87,164 KB
実行使用メモリ 135,812 KB
最終ジャッジ日時 2023-08-17 02:58:04
合計ジャッジ時間 25,009 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,364 KB
testcase_01 AC 72 ms
71,652 KB
testcase_02 AC 73 ms
71,260 KB
testcase_03 AC 1,475 ms
135,784 KB
testcase_04 AC 1,431 ms
135,812 KB
testcase_05 AC 152 ms
79,544 KB
testcase_06 AC 137 ms
79,288 KB
testcase_07 AC 97 ms
77,088 KB
testcase_08 AC 74 ms
76,164 KB
testcase_09 AC 69 ms
71,408 KB
testcase_10 AC 69 ms
71,304 KB
testcase_11 AC 290 ms
88,404 KB
testcase_12 AC 936 ms
124,596 KB
testcase_13 AC 948 ms
121,748 KB
testcase_14 AC 1,164 ms
132,884 KB
testcase_15 AC 115 ms
78,068 KB
testcase_16 AC 909 ms
119,936 KB
testcase_17 AC 112 ms
78,088 KB
testcase_18 AC 243 ms
84,928 KB
testcase_19 AC 939 ms
124,840 KB
testcase_20 AC 538 ms
101,816 KB
testcase_21 AC 751 ms
110,544 KB
testcase_22 AC 860 ms
117,660 KB
testcase_23 AC 898 ms
117,772 KB
testcase_24 AC 549 ms
102,048 KB
testcase_25 AC 604 ms
102,180 KB
testcase_26 AC 732 ms
110,316 KB
testcase_27 AC 729 ms
112,916 KB
testcase_28 AC 699 ms
106,448 KB
testcase_29 AC 1,088 ms
133,068 KB
testcase_30 AC 749 ms
111,612 KB
testcase_31 AC 841 ms
118,836 KB
testcase_32 AC 634 ms
107,092 KB
testcase_33 AC 940 ms
118,236 KB
testcase_34 AC 260 ms
86,280 KB
testcase_35 AC 628 ms
105,740 KB
testcase_36 AC 584 ms
101,036 KB
testcase_37 AC 278 ms
86,656 KB
testcase_38 AC 511 ms
97,536 KB
testcase_39 AC 168 ms
80,820 KB
testcase_40 AC 324 ms
90,184 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