結果

問題 No.2019 Digits Filling for All Substrings
ユーザー ああいいああいい
提出日時 2022-07-24 16:00:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 190 ms / 2,000 ms
コード長 544 bytes
コンパイル時間 277 ms
コンパイル使用メモリ 86,744 KB
実行使用メモリ 97,768 KB
最終ジャッジ日時 2023-09-20 15:31:33
合計ジャッジ時間 6,202 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,108 KB
testcase_01 AC 72 ms
71,152 KB
testcase_02 AC 71 ms
71,152 KB
testcase_03 AC 73 ms
71,072 KB
testcase_04 AC 149 ms
90,924 KB
testcase_05 AC 129 ms
86,352 KB
testcase_06 AC 122 ms
85,772 KB
testcase_07 AC 113 ms
82,912 KB
testcase_08 AC 169 ms
97,520 KB
testcase_09 AC 187 ms
97,396 KB
testcase_10 AC 187 ms
97,724 KB
testcase_11 AC 188 ms
97,384 KB
testcase_12 AC 188 ms
97,392 KB
testcase_13 AC 184 ms
97,768 KB
testcase_14 AC 91 ms
76,584 KB
testcase_15 AC 89 ms
76,448 KB
testcase_16 AC 91 ms
76,452 KB
testcase_17 AC 89 ms
76,700 KB
testcase_18 AC 91 ms
76,692 KB
testcase_19 AC 72 ms
71,144 KB
testcase_20 AC 73 ms
71,484 KB
testcase_21 AC 70 ms
71,336 KB
testcase_22 AC 73 ms
71,420 KB
testcase_23 AC 72 ms
71,296 KB
testcase_24 AC 140 ms
86,012 KB
testcase_25 AC 167 ms
90,324 KB
testcase_26 AC 123 ms
83,228 KB
testcase_27 AC 85 ms
76,400 KB
testcase_28 AC 84 ms
76,660 KB
testcase_29 AC 160 ms
88,868 KB
testcase_30 AC 190 ms
94,204 KB
testcase_31 AC 189 ms
93,580 KB
testcase_32 AC 119 ms
81,836 KB
testcase_33 AC 183 ms
89,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = input()
P = 998244353

dp = [[0] * 3 for _ in range(N + 1)]
#dp[0][0] = 1

ans = 0
for i in range(1,N + 1):
    s = S[i-1]

    if s != "?":
        c = int(s)
        for j in range(3):
            dp[i][(j * 10 + c) % 3] += dp[i-1][j]
        dp[i][c % 3] += 1
    else:
        for c in range(10):
            for j in range(3):
                dp[i][(j * 10 + c) % 3] += dp[i-1][j]
            dp[i][c % 3] += 1
    for j in range(3):
        dp[i][j] %= P
    ans += dp[i][0]
    ans %= P
print(ans)
            
    
0