結果

問題 No.2019 Digits Filling for All Substrings
ユーザー 👑 KazunKazun
提出日時 2022-07-22 23:09:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 181 ms / 2,000 ms
コード長 490 bytes
コンパイル時間 817 ms
コンパイル使用メモリ 86,920 KB
実行使用メモリ 96,712 KB
最終ジャッジ日時 2023-09-17 11:59:07
合計ジャッジ時間 6,422 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,172 KB
testcase_01 AC 72 ms
71,308 KB
testcase_02 AC 72 ms
71,212 KB
testcase_03 AC 74 ms
71,392 KB
testcase_04 AC 142 ms
90,000 KB
testcase_05 AC 124 ms
85,056 KB
testcase_06 AC 120 ms
83,868 KB
testcase_07 AC 110 ms
82,188 KB
testcase_08 AC 166 ms
96,712 KB
testcase_09 AC 176 ms
96,684 KB
testcase_10 AC 175 ms
96,364 KB
testcase_11 AC 175 ms
96,644 KB
testcase_12 AC 175 ms
96,668 KB
testcase_13 AC 177 ms
96,280 KB
testcase_14 AC 90 ms
76,540 KB
testcase_15 AC 92 ms
76,840 KB
testcase_16 AC 104 ms
77,524 KB
testcase_17 AC 94 ms
76,516 KB
testcase_18 AC 93 ms
76,528 KB
testcase_19 AC 78 ms
70,836 KB
testcase_20 AC 74 ms
71,064 KB
testcase_21 AC 75 ms
70,984 KB
testcase_22 AC 74 ms
71,260 KB
testcase_23 AC 75 ms
71,100 KB
testcase_24 AC 129 ms
83,140 KB
testcase_25 AC 151 ms
86,808 KB
testcase_26 AC 115 ms
80,944 KB
testcase_27 AC 85 ms
76,360 KB
testcase_28 AC 86 ms
76,180 KB
testcase_29 AC 154 ms
86,364 KB
testcase_30 AC 179 ms
90,720 KB
testcase_31 AC 181 ms
90,492 KB
testcase_32 AC 118 ms
80,340 KB
testcase_33 AC 157 ms
87,044 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(x):
    if x=="?":
        return -1
    else:
        return int(x)

N=int(input())
S=["*"]+list(map(f,input()))

Ans=0
Y=[0,0,0]
Mod=998244353
for i in range(1,N+1):
    X=Y.copy()
    Y=[0,0,0]
    if S[i]==-1:
        for c in range(10):
            Y[c%3]+=1
            for d in [0,1,2]:
                Y[(d+c)%3]+=X[d]
    else:
        Y[S[i]%3]+=1
        for d in [0,1,2]:
            Y[(d+S[i])%3]+=X[d]

    Y=[Y[0]%Mod, Y[1]%Mod, Y[2]%Mod]
    Ans+=Y[0]

print(Ans%Mod)
0