結果

問題 No.1740 Alone 'a'
ユーザー mrngmrng
提出日時 2021-11-19 22:05:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 266 ms / 2,000 ms
コード長 559 bytes
コンパイル時間 337 ms
コンパイル使用メモリ 86,968 KB
実行使用メモリ 126,768 KB
最終ジャッジ日時 2023-08-30 08:36:58
合計ジャッジ時間 9,673 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,340 KB
testcase_01 AC 74 ms
71,596 KB
testcase_02 AC 76 ms
71,176 KB
testcase_03 AC 266 ms
126,768 KB
testcase_04 AC 259 ms
126,728 KB
testcase_05 AC 99 ms
79,092 KB
testcase_06 AC 95 ms
76,848 KB
testcase_07 AC 87 ms
76,756 KB
testcase_08 AC 78 ms
71,180 KB
testcase_09 AC 74 ms
71,188 KB
testcase_10 AC 72 ms
71,268 KB
testcase_11 AC 125 ms
86,424 KB
testcase_12 AC 228 ms
117,292 KB
testcase_13 AC 225 ms
115,292 KB
testcase_14 AC 254 ms
124,288 KB
testcase_15 AC 90 ms
76,800 KB
testcase_16 AC 220 ms
113,472 KB
testcase_17 AC 92 ms
76,928 KB
testcase_18 AC 114 ms
81,404 KB
testcase_19 AC 230 ms
117,192 KB
testcase_20 AC 166 ms
98,120 KB
testcase_21 AC 194 ms
105,744 KB
testcase_22 AC 212 ms
111,436 KB
testcase_23 AC 211 ms
111,584 KB
testcase_24 AC 167 ms
98,400 KB
testcase_25 AC 168 ms
98,592 KB
testcase_26 AC 190 ms
105,248 KB
testcase_27 AC 203 ms
107,484 KB
testcase_28 AC 182 ms
101,556 KB
testcase_29 AC 259 ms
124,352 KB
testcase_30 AC 198 ms
106,504 KB
testcase_31 AC 221 ms
112,644 KB
testcase_32 AC 185 ms
102,528 KB
testcase_33 AC 222 ms
112,260 KB
testcase_34 AC 115 ms
81,424 KB
testcase_35 AC 177 ms
101,456 KB
testcase_36 AC 164 ms
97,424 KB
testcase_37 AC 122 ms
84,944 KB
testcase_38 AC 153 ms
94,472 KB
testcase_39 AC 106 ms
80,236 KB
testcase_40 AC 130 ms
88,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = input()
dp = [[[0,0] for _ in range(2)]for _ in range(n+1)]
dp[0][0][0] = 1
mod = 998244353
for i in range(n):
	dp[i+1][1][1] = dp[i][1][1]*25
	dp[i+1][0][1] = dp[i][0][1]*25
	dp[i+1][1][1] += dp[i][0][1]
	d = ord(s[i])-ord('a')-1
	dp[i+1][1][1] += dp[i][1][0]*max(0,d)
	dp[i+1][0][1] += dp[i][0][0]*max(0,d)
	if s[i]=='a':
		dp[i+1][1][0] += dp[i][0][0]
	else:
		dp[i+1][0][0] += dp[i][0][0]
		dp[i+1][1][0] += dp[i][1][0]
		dp[i+1][1][1] += 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