結果

問題 No.1740 Alone 'a'
ユーザー rlangevinrlangevin
提出日時 2023-08-08 12:21:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 838 ms / 2,000 ms
コード長 911 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 82,368 KB
実行使用メモリ 132,680 KB
最終ジャッジ日時 2024-04-26 05:18:04
合計ジャッジ時間 16,541 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
52,224 KB
testcase_01 AC 41 ms
52,224 KB
testcase_02 AC 43 ms
52,352 KB
testcase_03 AC 838 ms
132,624 KB
testcase_04 AC 830 ms
132,680 KB
testcase_05 AC 108 ms
78,088 KB
testcase_06 AC 107 ms
78,140 KB
testcase_07 AC 73 ms
68,480 KB
testcase_08 AC 47 ms
59,136 KB
testcase_09 AC 41 ms
51,840 KB
testcase_10 AC 41 ms
52,096 KB
testcase_11 AC 214 ms
86,584 KB
testcase_12 AC 643 ms
119,888 KB
testcase_13 AC 631 ms
117,152 KB
testcase_14 AC 738 ms
127,672 KB
testcase_15 AC 79 ms
72,196 KB
testcase_16 AC 593 ms
116,020 KB
testcase_17 AC 81 ms
71,916 KB
testcase_18 AC 170 ms
83,456 KB
testcase_19 AC 638 ms
120,236 KB
testcase_20 AC 378 ms
99,540 KB
testcase_21 AC 478 ms
107,476 KB
testcase_22 AC 563 ms
113,712 KB
testcase_23 AC 559 ms
113,428 KB
testcase_24 AC 376 ms
99,464 KB
testcase_25 AC 375 ms
99,608 KB
testcase_26 AC 477 ms
106,704 KB
testcase_27 AC 495 ms
109,040 KB
testcase_28 AC 426 ms
103,160 KB
testcase_29 AC 736 ms
127,664 KB
testcase_30 AC 489 ms
108,136 KB
testcase_31 AC 576 ms
115,008 KB
testcase_32 AC 433 ms
103,916 KB
testcase_33 AC 563 ms
114,364 KB
testcase_34 AC 183 ms
84,828 KB
testcase_35 AC 417 ms
102,356 KB
testcase_36 AC 359 ms
98,144 KB
testcase_37 AC 190 ms
84,868 KB
testcase_38 AC 322 ms
95,104 KB
testcase_39 AC 121 ms
79,504 KB
testcase_40 AC 234 ms
88,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = list(input())
mod = 998244353
for i in range(N):
    S[i] = ord(S[i]) - ord("a")

dp = [[[0] * 2 for i in range(2)] for i in range(N + 1)]
dp[0][0][0] = 1
for i in range(N):
    for a in range(2):
        for b in range(2):
            for n in range(26):
                if a == 0:
                    if n > S[i]:
                        continue
                    if n == S[i]:
                        na = 0
                    else:
                        na = 1
                else:
                    na = 1

                if b == 1:
                    if n == 0:
                        continue
                    nb = 1
                else:
                    if n == 0:
                        nb = 1
                    else:
                        nb = 0

                dp[i + 1][na][nb] += dp[i][a][b]
                dp[i + 1][na][nb] %= mod

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