結果

問題 No.1740 Alone 'a'
ユーザー HydruHydru
提出日時 2021-11-13 14:57:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 268 ms / 2,000 ms
コード長 615 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 87,196 KB
実行使用メモリ 126,744 KB
最終ジャッジ日時 2023-08-18 07:25:47
合計ジャッジ時間 8,384 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,376 KB
testcase_01 AC 70 ms
71,272 KB
testcase_02 AC 70 ms
71,520 KB
testcase_03 AC 268 ms
126,588 KB
testcase_04 AC 254 ms
126,744 KB
testcase_05 AC 90 ms
76,904 KB
testcase_06 AC 89 ms
76,760 KB
testcase_07 AC 82 ms
76,732 KB
testcase_08 AC 71 ms
71,536 KB
testcase_09 AC 73 ms
71,328 KB
testcase_10 AC 68 ms
71,200 KB
testcase_11 AC 120 ms
86,556 KB
testcase_12 AC 223 ms
116,860 KB
testcase_13 AC 220 ms
115,052 KB
testcase_14 AC 249 ms
124,096 KB
testcase_15 AC 86 ms
76,628 KB
testcase_16 AC 211 ms
113,288 KB
testcase_17 AC 86 ms
76,700 KB
testcase_18 AC 105 ms
81,140 KB
testcase_19 AC 218 ms
117,260 KB
testcase_20 AC 158 ms
98,012 KB
testcase_21 AC 182 ms
105,344 KB
testcase_22 AC 203 ms
111,448 KB
testcase_23 AC 199 ms
111,428 KB
testcase_24 AC 159 ms
98,104 KB
testcase_25 AC 164 ms
98,184 KB
testcase_26 AC 185 ms
105,108 KB
testcase_27 AC 199 ms
107,392 KB
testcase_28 AC 173 ms
101,500 KB
testcase_29 AC 253 ms
124,436 KB
testcase_30 AC 193 ms
106,212 KB
testcase_31 AC 214 ms
112,708 KB
testcase_32 AC 180 ms
101,344 KB
testcase_33 AC 208 ms
111,940 KB
testcase_34 AC 107 ms
81,268 KB
testcase_35 AC 173 ms
101,224 KB
testcase_36 AC 158 ms
97,160 KB
testcase_37 AC 107 ms
81,096 KB
testcase_38 AC 146 ms
94,340 KB
testcase_39 AC 100 ms
79,936 KB
testcase_40 AC 125 ms
87,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
S=input()
mod=998244353
DP=[[[0]*2 for _ in range(2)] for _ in range(N+1)]

DP[0][0][0]=1
for i in range(N):
    DP[i+1][1][1]+=25*DP[i][1][1]
    DP[i+1][0][1]+=25*DP[i][0][1]

    DP[i+1][1][1]+=DP[i][0][1]
    
    now=ord(S[i])-ord("a")

    if now!=0:
        DP[i+1][1][1]+=DP[i][0][0]
        DP[i+1][1][1]+=(now-1)*DP[i][1][0]
        DP[i+1][0][1]+=(now-1)*DP[i][0][0]
        DP[i+1][0][0]+=DP[i][0][0]
        DP[i+1][1][0]+=DP[i][1][0]
    else:
        DP[i+1][1][0]+=DP[i][0][0]
    
    for j in range(2):
        for k in range(2):
            DP[i+1][j][k]%=mod

print(DP[N][1][1])

0