結果

問題 No.1740 Alone 'a'
ユーザー 👑 rin204rin204
提出日時 2022-01-23 07:49:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 672 bytes
コンパイル時間 328 ms
コンパイル使用メモリ 86,992 KB
実行使用メモリ 128,232 KB
最終ジャッジ日時 2023-08-19 10:55:27
合計ジャッジ時間 9,228 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,140 KB
testcase_01 AC 69 ms
71,168 KB
testcase_02 AC 70 ms
71,336 KB
testcase_03 AC 246 ms
128,232 KB
testcase_04 AC 246 ms
128,228 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 71 ms
71,496 KB
testcase_09 AC 73 ms
71,496 KB
testcase_10 AC 72 ms
71,500 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 214 ms
115,856 KB
testcase_14 WA -
testcase_15 AC 85 ms
76,760 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 181 ms
108,072 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 184 ms
107,676 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 106 ms
81,204 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353

n = int(input())
S = input()
S = [ord(s) - 97 for s in S]

# dp[i][eq][a]
dp = [[[0] * 2 for _ in range(2)] for _ in range(n + 1)]
dp[0][1][0] = 1
for i, s in enumerate(S, 1):
    if s == 0:
        dp[i][0][1] = dp[i - 1][0][0] + dp[i - 1][0][1] * 25
        dp[i][1][1] = dp[i - 1][1][0]
    else:
        dp[i][0][0] = dp[i - 1][0][0] * 25 + dp[i - 1][1][0] * (s - 1)
        dp[i][0][1] = dp[i - 1][0][0] + dp[i - 1][0][1] * 25 + dp[i - 1][1][0] + dp[i - 1][1][1] * (s - 1)
        dp[i][1][0] = dp[i - 1][1][0]
        dp[i][1][1] = dp[i - 1][1][1]
    for j in range(2):
        for k in range(2):
            dp[i][j][k] %= MOD

print(dp[-1][0][1])
0