結果

問題 No.1740 Alone 'a'
ユーザー Eki1009Eki1009
提出日時 2021-11-12 22:09:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 224 ms / 2,000 ms
コード長 894 bytes
コンパイル時間 428 ms
コンパイル使用メモリ 87,116 KB
実行使用メモリ 79,544 KB
最終ジャッジ日時 2023-08-17 01:48:33
合計ジャッジ時間 8,520 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,212 KB
testcase_01 AC 71 ms
71,260 KB
testcase_02 AC 70 ms
71,308 KB
testcase_03 AC 221 ms
79,364 KB
testcase_04 AC 218 ms
79,480 KB
testcase_05 AC 114 ms
77,636 KB
testcase_06 AC 113 ms
77,444 KB
testcase_07 AC 97 ms
77,124 KB
testcase_08 AC 74 ms
71,440 KB
testcase_09 AC 74 ms
71,228 KB
testcase_10 AC 78 ms
71,436 KB
testcase_11 AC 133 ms
78,100 KB
testcase_12 AC 209 ms
79,408 KB
testcase_13 AC 204 ms
79,208 KB
testcase_14 AC 224 ms
79,408 KB
testcase_15 AC 108 ms
77,516 KB
testcase_16 AC 195 ms
78,712 KB
testcase_17 AC 106 ms
77,448 KB
testcase_18 AC 127 ms
77,632 KB
testcase_19 AC 208 ms
79,240 KB
testcase_20 AC 159 ms
78,324 KB
testcase_21 AC 179 ms
78,656 KB
testcase_22 AC 193 ms
78,844 KB
testcase_23 AC 195 ms
78,944 KB
testcase_24 AC 161 ms
78,296 KB
testcase_25 AC 159 ms
78,396 KB
testcase_26 AC 181 ms
78,828 KB
testcase_27 AC 185 ms
79,000 KB
testcase_28 AC 173 ms
78,600 KB
testcase_29 AC 221 ms
79,544 KB
testcase_30 AC 183 ms
78,892 KB
testcase_31 AC 199 ms
78,888 KB
testcase_32 AC 176 ms
78,284 KB
testcase_33 AC 196 ms
79,088 KB
testcase_34 AC 131 ms
77,928 KB
testcase_35 AC 167 ms
78,692 KB
testcase_36 AC 158 ms
78,120 KB
testcase_37 AC 132 ms
77,876 KB
testcase_38 AC 156 ms
78,024 KB
testcase_39 AC 119 ms
77,508 KB
testcase_40 AC 138 ms
78,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
n = int(input())
S = [ord(s)-ord("a") for s in input()]
dp = [[0]*2 for _ in range(2)]
dp[0][0] = 1
for s in S:
    ndp = [[0]*2 for _ in range(2)]
    for j0 in range(2):
        for k0 in range(2):
            for j1 in range(2):
                for k1 in range(2):
                    if j0 > j1 or k0 > k1:
                        continue
                    if k0 < k1:
                        if not (j0 or (j1 ^ (s == 0))):
                            continue
                        c = 1
                    else:
                        if (j0,j1) == (0,0):
                            c = s > 0
                        elif (j0,j1) == (0,1):
                            c = max(s-1,0)
                        else:
                            c = 25
                    ndp[j1][k1] += dp[j0][k0]*c
                    ndp[j1][k1] %= mod
    dp = ndp
print(dp[1][1])
0