結果

問題 No.2019 Digits Filling for All Substrings
ユーザー rlangevinrlangevin
提出日時 2023-11-28 12:33:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 213 ms / 2,000 ms
コード長 662 bytes
コンパイル時間 390 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 103,756 KB
最終ジャッジ日時 2023-11-28 12:33:55
合計ジャッジ時間 6,399 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,460 KB
testcase_01 AC 39 ms
53,460 KB
testcase_02 AC 39 ms
53,460 KB
testcase_03 AC 39 ms
53,460 KB
testcase_04 AC 141 ms
94,376 KB
testcase_05 AC 118 ms
89,184 KB
testcase_06 AC 119 ms
87,684 KB
testcase_07 AC 100 ms
84,404 KB
testcase_08 AC 186 ms
103,476 KB
testcase_09 AC 199 ms
103,756 KB
testcase_10 AC 199 ms
103,756 KB
testcase_11 AC 198 ms
103,748 KB
testcase_12 AC 198 ms
103,756 KB
testcase_13 AC 195 ms
103,756 KB
testcase_14 AC 63 ms
66,672 KB
testcase_15 AC 64 ms
68,740 KB
testcase_16 AC 67 ms
70,800 KB
testcase_17 AC 66 ms
68,736 KB
testcase_18 AC 66 ms
68,736 KB
testcase_19 AC 38 ms
53,460 KB
testcase_20 AC 38 ms
53,460 KB
testcase_21 AC 37 ms
53,460 KB
testcase_22 AC 38 ms
53,460 KB
testcase_23 AC 40 ms
53,460 KB
testcase_24 AC 141 ms
88,464 KB
testcase_25 AC 174 ms
93,700 KB
testcase_26 AC 116 ms
84,556 KB
testcase_27 AC 52 ms
64,536 KB
testcase_28 AC 50 ms
64,536 KB
testcase_29 AC 169 ms
92,380 KB
testcase_30 AC 213 ms
98,856 KB
testcase_31 AC 209 ms
98,172 KB
testcase_32 AC 110 ms
82,732 KB
testcase_33 AC 150 ms
93,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = list(input())
dp = [[0] * 3 for _ in range(N)]
mod = 998244353
for i in range(N):
    s = S[i]
    if ord("0") <= ord(s) <= ord("9"):
        s = int(s)
        for j in range(3):
            dp[i][(j + s) % 3] += dp[i-1][j]
            dp[i][(j + s) % 3] %= mod
        dp[i][s % 3] += 1
        dp[i][s % 3] %= mod
    else:
        for j in range(3):
            for k in range(10):
                dp[i][(j + k) % 3] += dp[i-1][j]
                dp[i][(j + k) % 3] %= mod
        for k in range(10):
            dp[i][k % 3] += 1
            dp[i][k % 3] %= mod

ans = 0
for i in range(N):
    ans += dp[i][0]
    ans %= mod

print(ans)
0