結果

問題 No.1740 Alone 'a'
ユーザー roarisroaris
提出日時 2021-11-12 22:00:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 729 ms / 2,000 ms
コード長 576 bytes
コンパイル時間 356 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 127,088 KB
最終ジャッジ日時 2023-08-17 01:27:53
合計ジャッジ時間 16,581 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
71,540 KB
testcase_01 AC 94 ms
71,768 KB
testcase_02 AC 100 ms
71,692 KB
testcase_03 AC 724 ms
127,076 KB
testcase_04 AC 729 ms
127,088 KB
testcase_05 AC 158 ms
79,920 KB
testcase_06 AC 154 ms
77,956 KB
testcase_07 AC 137 ms
77,896 KB
testcase_08 AC 105 ms
71,328 KB
testcase_09 AC 103 ms
71,692 KB
testcase_10 AC 103 ms
71,540 KB
testcase_11 AC 241 ms
87,000 KB
testcase_12 AC 554 ms
117,808 KB
testcase_13 AC 504 ms
115,108 KB
testcase_14 AC 595 ms
125,204 KB
testcase_15 AC 125 ms
78,700 KB
testcase_16 AC 473 ms
113,868 KB
testcase_17 AC 125 ms
78,376 KB
testcase_18 AC 187 ms
84,008 KB
testcase_19 AC 516 ms
117,856 KB
testcase_20 AC 335 ms
98,716 KB
testcase_21 AC 406 ms
105,968 KB
testcase_22 AC 525 ms
111,688 KB
testcase_23 AC 459 ms
111,848 KB
testcase_24 AC 331 ms
98,920 KB
testcase_25 AC 333 ms
99,080 KB
testcase_26 AC 399 ms
105,560 KB
testcase_27 AC 420 ms
108,128 KB
testcase_28 AC 377 ms
102,640 KB
testcase_29 AC 589 ms
124,916 KB
testcase_30 AC 444 ms
107,096 KB
testcase_31 AC 475 ms
113,244 KB
testcase_32 AC 378 ms
102,960 KB
testcase_33 AC 477 ms
112,564 KB
testcase_34 AC 198 ms
85,496 KB
testcase_35 AC 366 ms
101,876 KB
testcase_36 AC 323 ms
97,788 KB
testcase_37 AC 208 ms
85,776 KB
testcase_38 AC 293 ms
94,812 KB
testcase_39 AC 153 ms
80,860 KB
testcase_40 AC 229 ms
88,728 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