結果

問題 No.1740 Alone 'a'
ユーザー brthyyjpbrthyyjp
提出日時 2021-11-12 22:16:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 712 ms / 2,000 ms
コード長 799 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 87,340 KB
実行使用メモリ 126,780 KB
最終ジャッジ日時 2023-08-17 01:59:17
合計ジャッジ時間 15,190 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,400 KB
testcase_01 AC 72 ms
71,424 KB
testcase_02 AC 71 ms
71,232 KB
testcase_03 AC 696 ms
126,780 KB
testcase_04 AC 712 ms
126,556 KB
testcase_05 AC 116 ms
79,056 KB
testcase_06 AC 111 ms
78,536 KB
testcase_07 AC 89 ms
76,816 KB
testcase_08 AC 74 ms
73,780 KB
testcase_09 AC 71 ms
71,412 KB
testcase_10 AC 71 ms
71,332 KB
testcase_11 AC 199 ms
86,400 KB
testcase_12 AC 554 ms
117,200 KB
testcase_13 AC 542 ms
114,628 KB
testcase_14 AC 654 ms
124,316 KB
testcase_15 AC 96 ms
76,884 KB
testcase_16 AC 518 ms
113,344 KB
testcase_17 AC 92 ms
76,840 KB
testcase_18 AC 167 ms
83,492 KB
testcase_19 AC 563 ms
116,920 KB
testcase_20 AC 339 ms
98,280 KB
testcase_21 AC 427 ms
105,880 KB
testcase_22 AC 491 ms
111,192 KB
testcase_23 AC 486 ms
111,228 KB
testcase_24 AC 340 ms
98,256 KB
testcase_25 AC 336 ms
98,480 KB
testcase_26 AC 420 ms
104,892 KB
testcase_27 AC 443 ms
107,276 KB
testcase_28 AC 388 ms
101,768 KB
testcase_29 AC 655 ms
124,256 KB
testcase_30 AC 439 ms
106,472 KB
testcase_31 AC 515 ms
112,508 KB
testcase_32 AC 398 ms
102,592 KB
testcase_33 AC 501 ms
111,800 KB
testcase_34 AC 181 ms
84,648 KB
testcase_35 AC 380 ms
101,404 KB
testcase_36 AC 337 ms
97,384 KB
testcase_37 AC 183 ms
84,844 KB
testcase_38 AC 290 ms
94,188 KB
testcase_39 AC 123 ms
79,760 KB
testcase_40 AC 216 ms
87,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = str(input())
mod = 998244353
dp = [[[0]*2 for j in range(2)] for i in range(n+1)]
dp[0][0][0] = 1
for i, c in enumerate(s):
    c = ord(c)-ord('a')
    for j in range(2):
        for k in range(2):
            for d in range(26):
                ni = i+1
                nj = j
                nk = k
                if d == 0:
                    if j == 0:
                        nj += 1
                    else:
                        continue
                if k == 0:
                    if d > c:
                        continue
                    elif d < c:
                        nk = 1
                    else:
                        pass
                dp[ni][nj][nk] += dp[i][j][k]%mod
ans = sum(dp[n][1])
if s.count('a') == 1:
    ans -= 1
print(ans%mod)
0