結果

問題 No.2019 Digits Filling for All Substrings
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-07-22 22:52:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 299 ms / 2,000 ms
コード長 608 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 87,024 KB
実行使用メモリ 78,004 KB
最終ジャッジ日時 2023-09-17 11:27:49
合計ジャッジ時間 7,058 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,392 KB
testcase_01 AC 74 ms
71,496 KB
testcase_02 AC 74 ms
71,268 KB
testcase_03 AC 76 ms
71,368 KB
testcase_04 AC 222 ms
77,512 KB
testcase_05 AC 189 ms
77,424 KB
testcase_06 AC 183 ms
77,332 KB
testcase_07 AC 156 ms
77,252 KB
testcase_08 AC 297 ms
77,616 KB
testcase_09 AC 284 ms
77,676 KB
testcase_10 AC 256 ms
78,004 KB
testcase_11 AC 286 ms
77,652 KB
testcase_12 AC 287 ms
77,788 KB
testcase_13 AC 299 ms
77,772 KB
testcase_14 AC 101 ms
76,704 KB
testcase_15 AC 102 ms
76,952 KB
testcase_16 AC 112 ms
77,292 KB
testcase_17 AC 105 ms
77,012 KB
testcase_18 AC 104 ms
76,696 KB
testcase_19 AC 73 ms
71,272 KB
testcase_20 AC 74 ms
71,336 KB
testcase_21 AC 75 ms
71,268 KB
testcase_22 AC 75 ms
71,056 KB
testcase_23 AC 74 ms
71,568 KB
testcase_24 AC 151 ms
77,036 KB
testcase_25 AC 176 ms
77,328 KB
testcase_26 AC 132 ms
77,016 KB
testcase_27 AC 107 ms
76,632 KB
testcase_28 AC 106 ms
76,720 KB
testcase_29 AC 197 ms
77,376 KB
testcase_30 AC 253 ms
77,600 KB
testcase_31 AC 239 ms
77,596 KB
testcase_32 AC 144 ms
77,588 KB
testcase_33 AC 183 ms
77,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
S = input()
mod = 998244353

ans = 0

dp = [0]*3
for s in S:
    ndp = [0]*3

    for i in range(3):
        if dp[i] == 0:
            continue
        for j in range(10):
            if s == "?" or int(s) == j:
                x = j%3
                nx = (x+i)%3
                if nx == 0:
                    ans += dp[i]
                    ans %= mod
                ndp[nx] += dp[i]
                ndp[nx] %= mod
    
    for i in range(10):
        if s == "?" or int(s) == i:
            ndp[i%3] += 1
            if i%3 == 0:
                ans += 1
    dp = ndp

print(ans%mod)
0