結果

問題 No.2019 Digits Filling for All Substrings
ユーザー roarisroaris
提出日時 2022-08-05 14:38:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 253 ms / 2,000 ms
コード長 587 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 87,112 KB
実行使用メモリ 77,908 KB
最終ジャッジ日時 2023-10-13 13:32:32
合計ジャッジ時間 6,721 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
71,120 KB
testcase_01 AC 60 ms
71,292 KB
testcase_02 AC 60 ms
71,492 KB
testcase_03 AC 63 ms
76,112 KB
testcase_04 AC 174 ms
77,484 KB
testcase_05 AC 144 ms
77,600 KB
testcase_06 AC 117 ms
77,508 KB
testcase_07 AC 121 ms
77,592 KB
testcase_08 AC 208 ms
77,908 KB
testcase_09 AC 181 ms
77,728 KB
testcase_10 AC 182 ms
77,896 KB
testcase_11 AC 192 ms
77,824 KB
testcase_12 AC 188 ms
77,872 KB
testcase_13 AC 188 ms
77,600 KB
testcase_14 AC 79 ms
77,008 KB
testcase_15 AC 77 ms
76,980 KB
testcase_16 AC 84 ms
77,416 KB
testcase_17 AC 85 ms
76,644 KB
testcase_18 AC 93 ms
77,564 KB
testcase_19 AC 62 ms
71,400 KB
testcase_20 AC 62 ms
71,256 KB
testcase_21 AC 63 ms
71,332 KB
testcase_22 AC 64 ms
70,992 KB
testcase_23 AC 63 ms
71,368 KB
testcase_24 AC 198 ms
77,416 KB
testcase_25 AC 253 ms
77,324 KB
testcase_26 AC 164 ms
77,532 KB
testcase_27 AC 86 ms
77,224 KB
testcase_28 AC 85 ms
77,152 KB
testcase_29 AC 164 ms
77,384 KB
testcase_30 AC 194 ms
77,856 KB
testcase_31 AC 194 ms
77,652 KB
testcase_32 AC 132 ms
77,744 KB
testcase_33 AC 185 ms
77,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N = int(input())
S = input()[:-1]
dp = [[0]*3 for _ in range(2)]
dp[0][0] = 1
ans = 0
MOD = 998244353

for Si in S:
    ndp = [[0]*3 for _ in range(2)]
    
    for i in range(3):
        ndp[0][i] = dp[0][i]
    
    if Si=='?':
        nums = list(range(10))
    else:
        nums = [int(Si)]
    
    for i in range(2):
        for j in range(3):
            for num in nums:
                nj = (j+num)%3
                ndp[1][nj] += dp[i][j]
                ndp[1][nj] %= MOD
    
    dp = ndp
    ans += dp[1][0]
    ans %= MOD

print(ans)
0