結果

問題 No.1740 Alone 'a'
ユーザー kohei2019kohei2019
提出日時 2023-06-12 01:05:26
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 694 bytes
コンパイル時間 332 ms
コンパイル使用メモリ 87,208 KB
実行使用メモリ 93,544 KB
最終ジャッジ日時 2023-09-01 22:06:29
合計ジャッジ時間 6,136 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,492 KB
testcase_01 AC 70 ms
71,332 KB
testcase_02 AC 71 ms
71,244 KB
testcase_03 AC 119 ms
93,356 KB
testcase_04 AC 118 ms
93,512 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 72 ms
71,404 KB
testcase_09 AC 71 ms
71,080 KB
testcase_10 AC 69 ms
71,384 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
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 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = input()
mod = 998244353
# dp[i][j] i個目まで見て(j=0未満未確定,j=1未満確定,j=2 aが一つ未満未確定,j=3 aが一つ未満確定)
dp = [[0]*(4) for i in range(N+1)]
dp[0][0] = 1
a0 = ord('a')
for i in range(N):
    ord_s = ord(S[i])-a0
    if ord_s == 0:
        dp[i+1][2] += dp[i][0]
        dp[i+1][1] += dp[i][1]*25
        dp[i+1][3] += dp[i][1]
    else:
        dp[i+1][0] += dp[i][0]
        dp[i+1][1] += dp[i][0]*(ord_s-1)+dp[i][1]*25
        dp[i+1][3] += dp[i][0] + dp[i][1] + dp[i][2]*(ord_s-1)+dp[i][3]*25
        dp[i+1][2] += dp[i][2]
    dp[i+1][0] %= mod
    dp[i+1][1] %= mod
    dp[i+1][2] %= mod
    dp[i+1][3] %= mod
print(dp[-1][3])
0