結果

問題 No.1740 Alone 'a'
ユーザー brthyyjpbrthyyjp
提出日時 2021-11-12 22:16:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 717 ms / 2,000 ms
コード長 799 bytes
コンパイル時間 188 ms
コンパイル使用メモリ 82,336 KB
実行使用メモリ 125,648 KB
最終ジャッジ日時 2024-05-04 09:13:53
合計ジャッジ時間 14,366 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,096 KB
testcase_01 AC 40 ms
52,608 KB
testcase_02 AC 40 ms
52,224 KB
testcase_03 AC 716 ms
125,648 KB
testcase_04 AC 717 ms
125,440 KB
testcase_05 AC 92 ms
77,644 KB
testcase_06 AC 81 ms
73,344 KB
testcase_07 AC 57 ms
65,152 KB
testcase_08 AC 42 ms
56,192 KB
testcase_09 AC 39 ms
51,968 KB
testcase_10 AC 39 ms
52,096 KB
testcase_11 AC 177 ms
85,120 KB
testcase_12 AC 559 ms
115,836 KB
testcase_13 AC 545 ms
113,432 KB
testcase_14 AC 645 ms
123,008 KB
testcase_15 AC 64 ms
67,968 KB
testcase_16 AC 508 ms
112,000 KB
testcase_17 AC 65 ms
67,968 KB
testcase_18 AC 141 ms
80,292 KB
testcase_19 AC 561 ms
115,848 KB
testcase_20 AC 319 ms
96,836 KB
testcase_21 AC 419 ms
104,456 KB
testcase_22 AC 500 ms
110,488 KB
testcase_23 AC 492 ms
109,952 KB
testcase_24 AC 326 ms
97,024 KB
testcase_25 AC 339 ms
97,280 KB
testcase_26 AC 413 ms
103,820 KB
testcase_27 AC 435 ms
106,112 KB
testcase_28 AC 377 ms
100,972 KB
testcase_29 AC 652 ms
123,008 KB
testcase_30 AC 430 ms
104,964 KB
testcase_31 AC 518 ms
111,232 KB
testcase_32 AC 383 ms
101,340 KB
testcase_33 AC 499 ms
110,592 KB
testcase_34 AC 157 ms
83,200 KB
testcase_35 AC 363 ms
99,840 KB
testcase_36 AC 313 ms
95,988 KB
testcase_37 AC 161 ms
83,496 KB
testcase_38 AC 272 ms
92,800 KB
testcase_39 AC 97 ms
78,560 KB
testcase_40 AC 194 ms
86,612 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