結果

問題 No.1740 Alone 'a'
ユーザー roarisroaris
提出日時 2021-11-12 22:00:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 675 ms / 2,000 ms
コード長 576 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 82,124 KB
実行使用メモリ 126,136 KB
最終ジャッジ日時 2024-05-04 08:41:46
合計ジャッジ時間 13,068 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
53,504 KB
testcase_01 AC 42 ms
53,632 KB
testcase_02 AC 43 ms
53,888 KB
testcase_03 AC 663 ms
126,080 KB
testcase_04 AC 675 ms
126,136 KB
testcase_05 AC 102 ms
78,336 KB
testcase_06 AC 95 ms
77,696 KB
testcase_07 AC 72 ms
71,040 KB
testcase_08 AC 43 ms
54,272 KB
testcase_09 AC 43 ms
53,504 KB
testcase_10 AC 43 ms
53,632 KB
testcase_11 AC 175 ms
85,504 KB
testcase_12 AC 493 ms
116,608 KB
testcase_13 AC 465 ms
114,112 KB
testcase_14 AC 568 ms
123,264 KB
testcase_15 AC 79 ms
74,852 KB
testcase_16 AC 447 ms
112,768 KB
testcase_17 AC 78 ms
74,112 KB
testcase_18 AC 152 ms
82,688 KB
testcase_19 AC 488 ms
116,556 KB
testcase_20 AC 299 ms
97,152 KB
testcase_21 AC 379 ms
104,828 KB
testcase_22 AC 503 ms
110,464 KB
testcase_23 AC 433 ms
110,208 KB
testcase_24 AC 299 ms
97,684 KB
testcase_25 AC 299 ms
97,620 KB
testcase_26 AC 368 ms
104,320 KB
testcase_27 AC 388 ms
106,720 KB
testcase_28 AC 340 ms
101,504 KB
testcase_29 AC 556 ms
123,520 KB
testcase_30 AC 387 ms
106,356 KB
testcase_31 AC 449 ms
111,488 KB
testcase_32 AC 346 ms
102,144 KB
testcase_33 AC 444 ms
111,664 KB
testcase_34 AC 158 ms
83,584 KB
testcase_35 AC 332 ms
100,424 KB
testcase_36 AC 293 ms
96,640 KB
testcase_37 AC 160 ms
84,032 KB
testcase_38 AC 248 ms
93,440 KB
testcase_39 AC 111 ms
79,388 KB
testcase_40 AC 192 ms
87,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import *

N = int(input())
S = input()[:-1]
dp = [[[0]*2 for _ in range(2)] for _ in range(N+1)]
dp[0][0][0] = 1
MOD = 998244353

for i in range(N):
    d = ord(S[i])-ord('a')
    
    for j in range(2):
        for k in range(2):
            for c in range(26 if j else d+1):
                if k==1 and c==0:
                    continue
                
                nj = j|(c<d)
                nk = k+(c==0)
                dp[i+1][nj][nk] += dp[i][j][k]
                dp[i+1][nj][nk] %= MOD

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