結果

問題 No.2019 Digits Filling for All Substrings
ユーザー tassei903tassei903
提出日時 2022-07-22 22:40:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 238 ms / 2,000 ms
コード長 866 bytes
コンパイル時間 257 ms
コンパイル使用メモリ 87,096 KB
実行使用メモリ 116,296 KB
最終ジャッジ日時 2023-09-17 11:11:37
合計ジャッジ時間 6,622 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,420 KB
testcase_01 AC 70 ms
71,248 KB
testcase_02 AC 72 ms
70,972 KB
testcase_03 AC 72 ms
70,996 KB
testcase_04 AC 191 ms
102,920 KB
testcase_05 AC 165 ms
95,368 KB
testcase_06 AC 159 ms
93,424 KB
testcase_07 AC 139 ms
88,832 KB
testcase_08 AC 234 ms
115,868 KB
testcase_09 AC 233 ms
116,204 KB
testcase_10 AC 236 ms
116,296 KB
testcase_11 AC 238 ms
116,160 KB
testcase_12 AC 238 ms
116,200 KB
testcase_13 AC 233 ms
116,048 KB
testcase_14 AC 94 ms
76,524 KB
testcase_15 AC 94 ms
76,636 KB
testcase_16 AC 104 ms
79,364 KB
testcase_17 AC 98 ms
76,264 KB
testcase_18 AC 100 ms
77,124 KB
testcase_19 AC 72 ms
71,260 KB
testcase_20 AC 72 ms
71,088 KB
testcase_21 AC 74 ms
71,256 KB
testcase_22 AC 74 ms
71,236 KB
testcase_23 AC 73 ms
71,308 KB
testcase_24 AC 156 ms
94,560 KB
testcase_25 AC 188 ms
102,264 KB
testcase_26 AC 141 ms
89,028 KB
testcase_27 AC 108 ms
80,124 KB
testcase_28 AC 108 ms
80,172 KB
testcase_29 AC 183 ms
99,660 KB
testcase_30 AC 215 ms
109,332 KB
testcase_31 AC 217 ms
108,372 KB
testcase_32 AC 132 ms
86,024 KB
testcase_33 AC 189 ms
100,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################
n = ni()
def f(x):
    if x == "?":
        return [4,3,3]
    z = [0,0,0]
    z[int(x)%3] += 1
    return z
mod = 998244353
s = [f(i) for i in input()[::-1]]

dp = [[0 for i in range(3)] for k in range(1+n)]
for i in range(n):
    for j in range(3):
        for k in range(3):
            dp[i+1][j] += dp[i][(j-k)%3]*s[i][k]
            dp[i+1][j] %= mod
    for k in range(3):
        dp[i+1][k] += s[i][k]
        dp[i+1][k] %= mod
ans = 0
for i in range(1,n+1):
    ans += dp[i][0]
    ans %= mod
print(ans)
0