結果

問題 No.2019 Digits Filling for All Substrings
ユーザー taiga0629kyoprotaiga0629kyopro
提出日時 2022-08-20 03:03:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 212 ms / 2,000 ms
コード長 559 bytes
コンパイル時間 382 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 102,376 KB
最終ジャッジ日時 2024-04-17 04:58:11
合計ジャッジ時間 5,386 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
51,840 KB
testcase_01 AC 36 ms
51,968 KB
testcase_02 AC 38 ms
52,096 KB
testcase_03 AC 37 ms
52,352 KB
testcase_04 AC 140 ms
91,956 KB
testcase_05 AC 120 ms
88,624 KB
testcase_06 AC 107 ms
87,808 KB
testcase_07 AC 98 ms
84,480 KB
testcase_08 AC 182 ms
102,376 KB
testcase_09 AC 202 ms
100,004 KB
testcase_10 AC 201 ms
100,152 KB
testcase_11 AC 202 ms
100,276 KB
testcase_12 AC 199 ms
99,988 KB
testcase_13 AC 200 ms
100,640 KB
testcase_14 AC 59 ms
67,200 KB
testcase_15 AC 59 ms
67,712 KB
testcase_16 AC 69 ms
71,936 KB
testcase_17 AC 58 ms
67,328 KB
testcase_18 AC 60 ms
67,712 KB
testcase_19 AC 37 ms
52,096 KB
testcase_20 AC 37 ms
52,224 KB
testcase_21 AC 36 ms
52,224 KB
testcase_22 AC 36 ms
52,096 KB
testcase_23 AC 37 ms
52,352 KB
testcase_24 AC 136 ms
87,808 KB
testcase_25 AC 168 ms
89,736 KB
testcase_26 AC 108 ms
83,788 KB
testcase_27 AC 54 ms
67,200 KB
testcase_28 AC 53 ms
66,816 KB
testcase_29 AC 163 ms
88,796 KB
testcase_30 AC 207 ms
94,272 KB
testcase_31 AC 212 ms
94,104 KB
testcase_32 AC 110 ms
82,560 KB
testcase_33 AC 174 ms
89,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #


n=int(input())
s=[0]+list(input())
for i in range(1,n+1):
    if s[i]=="?":s[i]=-1
    else:s[i]=int(s[i])
dp=[[0,0,0] for i in range(n+3)]

mod=998244353

for i in range(1,n+1):
    for j in range(3):
        if s[i]>=0:
            dp[i][j]+=dp[i-1][(j-s[i])%3]
            dp[i][j]%=mod
            if j==s[i]%3:dp[i][j]+=1
        else:
            for x in range(10):
                dp[i][j]+=dp[i-1][(j-x)%3]
                dp[i][j]%=mod
                if j==x%3:dp[i][j]+=1
ans=0
for i in range(1,n+1):
    ans+=dp[i][0]
    ans%=mod
print(ans)


0