結果

問題 No.2219 Re:010
ユーザー 👑 timitimi
提出日時 2023-02-17 22:20:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 737 ms / 2,000 ms
コード長 699 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 86,928 KB
実行使用メモリ 118,600 KB
最終ジャッジ日時 2023-09-26 19:35:47
合計ジャッジ時間 8,668 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,356 KB
testcase_01 AC 73 ms
71,252 KB
testcase_02 AC 74 ms
71,228 KB
testcase_03 AC 458 ms
100,864 KB
testcase_04 AC 139 ms
78,596 KB
testcase_05 AC 380 ms
98,036 KB
testcase_06 AC 167 ms
81,652 KB
testcase_07 AC 263 ms
90,616 KB
testcase_08 AC 433 ms
101,208 KB
testcase_09 AC 421 ms
100,832 KB
testcase_10 AC 347 ms
100,588 KB
testcase_11 AC 307 ms
94,972 KB
testcase_12 AC 300 ms
95,076 KB
testcase_13 AC 524 ms
100,656 KB
testcase_14 AC 526 ms
100,884 KB
testcase_15 AC 527 ms
100,920 KB
testcase_16 AC 516 ms
100,740 KB
testcase_17 AC 517 ms
100,744 KB
testcase_18 AC 119 ms
117,956 KB
testcase_19 AC 120 ms
118,184 KB
testcase_20 AC 737 ms
118,600 KB
testcase_21 AC 74 ms
71,512 KB
testcase_22 AC 75 ms
71,360 KB
testcase_23 AC 75 ms
71,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S=input()
A,B,C=[0],[0],[0]
for s in S:
  if s=='0':
    A.append(A[-1]+1)
    B.append(B[-1])
    C.append(C[-1])
  elif s=='1':
    A.append(A[-1])
    B.append(B[-1]+1)
    C.append(C[-1])
  else:
    A.append(A[-1])
    B.append(B[-1])
    C.append(C[-1]+1)
ans=0
hh=C[-1]
mod=998244353
for i in range(len(S)):
  hl,hr=C[i],C[-1]-C[i+1]
  zl,zr=A[i],A[-1]-A[i+1]
  a,b,c,d=0,0,0,0
  if S[i]=='0':
    continue
  if S[i]=='?':
    a=zl*zr*pow(2,hh-1,mod)
  else:
    a=zl*zr*pow(2,hh,mod)
  if hl>0:
    b=hl*pow(2,hl-1,mod)*zr*pow(2,hr,mod)
  if hr>0:
    c=zl*pow(2,hl,mod)*hr*pow(2,hr-1,mod)
  if hl>0 and hr>0:
    d=hl*pow(2,hl-1,mod)*hr*pow(2,hr-1,mod)
  ans+=a+b+c+d 
  ans%=mod
print(ans)
0