結果

問題 No.2219 Re:010
コンテスト
ユーザー flygon
提出日時 2023-02-17 22:09:30
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
MLE  
実行時間 -
コード長 749 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 140 ms
コンパイル使用メモリ 85,444 KB
実行使用メモリ 2,677,824 KB
最終ジャッジ日時 2026-04-02 16:51:53
合計ジャッジ時間 17,023 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11 MLE * 8 -- * 2
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

s = input()
mod = 998244353
ans = 0
n = len(s)
pre = []
hate = []
last = 0
nowh = 0
for i in range(n):
  si = s[i]
  hate.append(last)
  if si == "0":
    last += pow(2, nowh, mod)
  elif si == "?":
    last *= 2 
    last += pow(2, nowh, mod)
    nowh += 1
  pre.append(last)

suf = []
hates = []
nowh = 0
last = 0
for i in range(n)[::-1]:
  si = s[i]
  hates.append(last)
  if si == "0":
    last += pow(2, nowh, mod)
  elif si == "?":
    last *= 2 
    last += pow(2, nowh, mod)
    nowh += 1
  last %= mod
  suf.append(last)

suf = suf[::-1]
hates = hates[::-1]
ans = 0
for i in range(1,n-1):
  if s[i] == "1":
    ans += pre[i] * suf[i] % mod
    ans %= mod
  elif s[i] == "?":
    ans += hate[i] * hates[i] % mod
    ans %= mod 
  
print(ans)
0