結果

問題 No.1740 Alone 'a'
ユーザー 👑 KazunKazun
提出日時 2021-10-17 02:20:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 725 bytes
コンパイル時間 431 ms
コンパイル使用メモリ 87,260 KB
実行使用メモリ 90,460 KB
最終ジャッジ日時 2023-08-16 20:47:31
合計ジャッジ時間 6,118 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,048 KB
testcase_01 AC 68 ms
71,304 KB
testcase_02 AC 70 ms
71,180 KB
testcase_03 AC 101 ms
90,460 KB
testcase_04 AC 100 ms
90,400 KB
testcase_05 AC 80 ms
76,232 KB
testcase_06 AC 87 ms
76,080 KB
testcase_07 AC 71 ms
71,384 KB
testcase_08 AC 70 ms
71,384 KB
testcase_09 AC 69 ms
71,212 KB
testcase_10 AC 70 ms
71,080 KB
testcase_11 AC 85 ms
77,760 KB
testcase_12 AC 99 ms
87,112 KB
testcase_13 AC 98 ms
87,152 KB
testcase_14 AC 102 ms
90,272 KB
testcase_15 AC 79 ms
76,068 KB
testcase_16 AC 99 ms
86,088 KB
testcase_17 AC 81 ms
75,920 KB
testcase_18 AC 81 ms
76,824 KB
testcase_19 AC 99 ms
87,292 KB
testcase_20 AC 92 ms
81,920 KB
testcase_21 AC 95 ms
83,408 KB
testcase_22 AC 97 ms
85,684 KB
testcase_23 AC 98 ms
85,836 KB
testcase_24 AC 92 ms
81,932 KB
testcase_25 AC 92 ms
81,784 KB
testcase_26 AC 97 ms
83,608 KB
testcase_27 AC 97 ms
84,192 KB
testcase_28 AC 94 ms
82,796 KB
testcase_29 AC 104 ms
90,376 KB
testcase_30 AC 95 ms
84,512 KB
testcase_31 AC 97 ms
85,984 KB
testcase_32 AC 94 ms
82,624 KB
testcase_33 AC 99 ms
85,852 KB
testcase_34 AC 85 ms
77,384 KB
testcase_35 AC 94 ms
82,612 KB
testcase_36 AC 93 ms
81,044 KB
testcase_37 AC 85 ms
77,184 KB
testcase_38 AC 91 ms
80,508 KB
testcase_39 AC 84 ms
76,420 KB
testcase_40 AC 89 ms
79,028 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