結果

問題 No.2019 Digits Filling for All Substrings
ユーザー googol_S0googol_S0
提出日時 2022-07-22 21:42:25
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 337 bytes
コンパイル時間 634 ms
コンパイル使用メモリ 87,108 KB
実行使用メモリ 78,264 KB
最終ジャッジ日時 2023-09-17 09:24:21
合計ジャッジ時間 5,033 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,396 KB
testcase_01 AC 74 ms
71,448 KB
testcase_02 AC 74 ms
71,116 KB
testcase_03 AC 75 ms
71,176 KB
testcase_04 AC 89 ms
77,340 KB
testcase_05 AC 86 ms
76,604 KB
testcase_06 AC 85 ms
76,700 KB
testcase_07 AC 84 ms
76,588 KB
testcase_08 AC 92 ms
78,136 KB
testcase_09 AC 92 ms
78,188 KB
testcase_10 AC 91 ms
78,084 KB
testcase_11 AC 92 ms
78,264 KB
testcase_12 AC 92 ms
78,196 KB
testcase_13 AC 93 ms
78,156 KB
testcase_14 AC 81 ms
75,940 KB
testcase_15 AC 81 ms
76,244 KB
testcase_16 AC 85 ms
76,140 KB
testcase_17 AC 83 ms
75,924 KB
testcase_18 AC 85 ms
76,264 KB
testcase_19 AC 74 ms
71,176 KB
testcase_20 AC 76 ms
71,144 KB
testcase_21 AC 74 ms
71,140 KB
testcase_22 AC 74 ms
71,164 KB
testcase_23 AC 75 ms
71,088 KB
testcase_24 AC 82 ms
76,492 KB
testcase_25 AC 83 ms
76,616 KB
testcase_26 AC 81 ms
76,108 KB
testcase_27 AC 81 ms
76,196 KB
testcase_28 AC 81 ms
76,056 KB
testcase_29 AC 87 ms
77,100 KB
testcase_30 AC 88 ms
77,508 KB
testcase_31 AC 90 ms
77,480 KB
testcase_32 AC 85 ms
76,384 KB
testcase_33 AC 88 ms
77,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
S=input()
ANS=0
X=[0]*N
mod=998244353
for i in range(N):
  if S[i]=='?':
    X[i]=0
  else:
    X[i]=int(S[i])%3
C=[0]*3
C[0]=1
v=0
for i in range(N):
  v=(v+X[i])%3
  C[v]+=1
for i in range(3):
  ANS=(ANS+(C[i]*(C[i]-1))//2)%mod
P=0
for i in range(N):
  if S[i]=='?':
    P=(P*10+(i+1)*3)%mod
  ANS=(ANS+P)%mod
print(ANS)
0