結果

問題 No.1740 Alone 'a'
ユーザー 👑 KazunKazun
提出日時 2021-10-17 02:20:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 725 bytes
コンパイル時間 144 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 89,472 KB
最終ジャッジ日時 2024-05-04 04:11:39
合計ジャッジ時間 3,946 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
51,712 KB
testcase_01 AC 38 ms
51,712 KB
testcase_02 AC 36 ms
51,968 KB
testcase_03 AC 80 ms
89,344 KB
testcase_04 AC 80 ms
89,344 KB
testcase_05 AC 56 ms
64,512 KB
testcase_06 AC 58 ms
65,408 KB
testcase_07 AC 42 ms
52,992 KB
testcase_08 AC 41 ms
52,096 KB
testcase_09 AC 37 ms
51,968 KB
testcase_10 AC 37 ms
51,712 KB
testcase_11 AC 61 ms
73,728 KB
testcase_12 AC 77 ms
86,272 KB
testcase_13 AC 78 ms
86,144 KB
testcase_14 AC 81 ms
89,472 KB
testcase_15 AC 50 ms
61,440 KB
testcase_16 AC 75 ms
84,864 KB
testcase_17 AC 49 ms
61,440 KB
testcase_18 AC 56 ms
69,888 KB
testcase_19 AC 81 ms
86,272 KB
testcase_20 AC 77 ms
80,768 KB
testcase_21 AC 73 ms
82,432 KB
testcase_22 AC 77 ms
84,864 KB
testcase_23 AC 78 ms
84,864 KB
testcase_24 AC 70 ms
80,640 KB
testcase_25 AC 69 ms
80,768 KB
testcase_26 AC 73 ms
82,432 KB
testcase_27 AC 75 ms
83,712 KB
testcase_28 AC 74 ms
81,664 KB
testcase_29 AC 81 ms
89,344 KB
testcase_30 AC 74 ms
83,456 KB
testcase_31 AC 81 ms
84,992 KB
testcase_32 AC 79 ms
81,664 KB
testcase_33 AC 83 ms
84,864 KB
testcase_34 AC 64 ms
71,424 KB
testcase_35 AC 71 ms
81,792 KB
testcase_36 AC 71 ms
80,000 KB
testcase_37 AC 59 ms
71,296 KB
testcase_38 AC 69 ms
79,872 KB
testcase_39 AC 54 ms
65,536 KB
testcase_40 AC 62 ms
75,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
S=list(map(lambda x:ord(x)-ord("a"),input())) # a->0, b->1, ..., y->24, z->25 に変換

DP=[[1,0],[0,0]] # DP[mode][flag]:=辞書式未満が確定して (いて/おらず), 'a' を使ってい (る/ない) 文字列の個数
Mod=998244353

for x in S:
    E=DP
    DP=[[0,0],[0,0]]

    # False -> False
    if x==0:
        DP[0][1]=E[0][0]
    else:
        DP[0][0]=E[0][0]
        DP[0][1]=E[0][1]

    # False -> True

    if x!=0:
        DP[1][1]=E[0][0]
        DP[1][0]+=E[0][0]*(x-1)
        DP[1][1]+=E[0][1]*(x-1)

    # True -> True
    DP[1][0]+=E[1][0]*25
    DP[1][1]+=E[1][0]
    DP[1][1]+=E[1][1]*25

    DP[0][0]%=Mod
    DP[0][1]%=Mod
    DP[1][0]%=Mod
    DP[1][1]%=Mod

print(DP[1][1])
0