結果

問題 No.2219 Re:010
ユーザー Hydru
提出日時 2023-02-18 00:00:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 413 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 89,984 KB
最終ジャッジ日時 2024-07-19 15:04:17
合計ジャッジ時間 3,385 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

mod=998244353

S=input()
len_S=len(S)

pow_2=[1]
for _ in range(len_S+1):
    pow_2.append(pow_2[-1]*2%mod)

D={"0":0,"1":1,"?":2}

cntr=[0,0,0]
cntl=[0,0,0]
for s in S:
    cntr[D[s]]+=1

ans=0
for s in S:
    cntr[D[s]]-=1
    if s!="0":
        x=cntl[2]
        y=cntr[2]
        ans+=(cntl[0]*pow_2[x]+x*pow_2[max(0,x-1)])*(cntr[0]*pow_2[y]+y*pow_2[max(0,y-1)])
        ans%=mod
    cntl[D[s]]+=1

print(ans)
0